@forestadmin/datasource-toolkit
Advanced tools
Comparing version 1.0.0-beta.21 to 1.0.0-beta.22
@@ -0,1 +1,8 @@ | ||
# @forestadmin/datasource-toolkit [1.0.0-beta.22](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/datasource-toolkit@1.0.0-beta.21...@forestadmin/datasource-toolkit@1.0.0-beta.22) (2022-06-09) | ||
### Bug Fixes | ||
* **decorators:** remove useless isRequired field ([#337](https://github.com/ForestAdmin/agent-nodejs/issues/337)) ([ed9dd04](https://github.com/ForestAdmin/agent-nodejs/commit/ed9dd040bea1fa9c07aaaf1bf634e45bd62827df)) | ||
# @forestadmin/datasource-toolkit [1.0.0-beta.21](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/datasource-toolkit@1.0.0-beta.20...@forestadmin/datasource-toolkit@1.0.0-beta.21) (2022-06-01) | ||
@@ -2,0 +9,0 @@ |
@@ -14,8 +14,100 @@ import { ActionField, ActionResult } from '../../interfaces/action'; | ||
constructor(collection: Collection, caller: Caller); | ||
/** | ||
* Execute a given action | ||
* @param name the name of the action | ||
* @param formValues the values of the form, if the action rely on an action form | ||
* @param filter the filter used to represent the selected records to use the action on | ||
* @example | ||
* .execute( | ||
* 'Refund', | ||
* { reason: 'Article is broken' }, | ||
* { | ||
* conditionTree: { | ||
* field: 'id', | ||
* operator: 'Equal', | ||
* value: 1 | ||
* } | ||
* } | ||
* ); | ||
*/ | ||
execute(name: string, formValues: RecordData, filter?: PlainFilter<S, N>): Promise<ActionResult>; | ||
getForm(name: string, formValues?: RecordData, filter?: PlainFilter<S, N>): Promise<ActionField[]>; | ||
/** | ||
* Create a list of records | ||
* @param data An array of records to create | ||
* @example | ||
* .create([ | ||
* { amountInEur: 150, description: 'Buy dvd' }, | ||
* { amountInEur: -100, description: 'Refund' }, | ||
* ]); | ||
*/ | ||
create(data: TSimpleRow<S, N>[]): Promise<TSimpleRow<S, N>[]>; | ||
/** | ||
* List multiple records | ||
* @param filter the filter used to select the records to list | ||
* @param projection an array of fields name representing the data to select | ||
* @example | ||
* .list({ | ||
* conditionTree: { | ||
* aggregator: 'And', | ||
* conditions: [{ | ||
* field: 'amountInEur', | ||
* operator: 'GreaterThan', | ||
* value: 1000 | ||
* }, { | ||
* field: 'description', | ||
* operator: 'Contains', | ||
* value: 'Refund', | ||
* }], | ||
* page: { limit: 10, skip: 0 }, | ||
* sort: [{ field: 'id', ascending: true }] | ||
* } | ||
* }, ['id', 'amountInEur', 'description']); | ||
*/ | ||
list(filter: PlainPaginatedFilter<S, N>, projection: TFieldName<S, N>[]): Promise<TRow<S, N>[]>; | ||
/** | ||
* Update a list of records | ||
* @param filter the filter that represent the list of records to update | ||
* @param patch the patch to apply on the selected records | ||
* @example | ||
* .update({ | ||
* conditionTree: { | ||
* field: 'isActive', | ||
* operator: 'Equal', | ||
* value: false | ||
* }, | ||
* }, { isActive: true }); | ||
*/ | ||
update(filter: PlainFilter<S, N>, patch: TPartialSimpleRow<S, N>): Promise<void>; | ||
/** | ||
* Delete a list of records | ||
* @param filter the filter that represent the list of records to update | ||
* @example | ||
* .delete({ | ||
* conditionTree: { | ||
* field: 'isBlocked', | ||
* operator: 'Equal', | ||
* value: false, | ||
* }, | ||
* }); | ||
*/ | ||
delete(filter: PlainFilter<S, N>): Promise<void>; | ||
/** | ||
* Aggregate a list of records | ||
* @param filter the filter used to list the records to aggregate | ||
* @param aggregation the aggregation to apply | ||
* @param limit the maximum number of result to return | ||
* @example | ||
* .aggregate({ | ||
* conditionTree: { | ||
* field: "user:company:id", | ||
* operator: "In", | ||
* value: records.map((r) => r.id), | ||
* }, | ||
* }, { | ||
* operation: "Sum", | ||
* field: "amountInEur", | ||
* groups: [{ field: "user:company:id" }], | ||
* }, 10); | ||
*/ | ||
aggregate(filter: PlainFilter<S, N>, aggregation: PlainAggregation<S, N>, limit?: number): Promise<AggregateResult<S, N>[]>; | ||
@@ -22,0 +114,0 @@ private buildFilter; |
@@ -19,2 +19,20 @@ "use strict"; | ||
} | ||
/** | ||
* Execute a given action | ||
* @param name the name of the action | ||
* @param formValues the values of the form, if the action rely on an action form | ||
* @param filter the filter used to represent the selected records to use the action on | ||
* @example | ||
* .execute( | ||
* 'Refund', | ||
* { reason: 'Article is broken' }, | ||
* { | ||
* conditionTree: { | ||
* field: 'id', | ||
* operator: 'Equal', | ||
* value: 1 | ||
* } | ||
* } | ||
* ); | ||
*/ | ||
execute(name, formValues, filter) { | ||
@@ -28,5 +46,36 @@ const filterInstance = this.buildFilter(filter); | ||
} | ||
/** | ||
* Create a list of records | ||
* @param data An array of records to create | ||
* @example | ||
* .create([ | ||
* { amountInEur: 150, description: 'Buy dvd' }, | ||
* { amountInEur: -100, description: 'Refund' }, | ||
* ]); | ||
*/ | ||
create(data) { | ||
return this.collection.create(this.caller, data); | ||
} | ||
/** | ||
* List multiple records | ||
* @param filter the filter used to select the records to list | ||
* @param projection an array of fields name representing the data to select | ||
* @example | ||
* .list({ | ||
* conditionTree: { | ||
* aggregator: 'And', | ||
* conditions: [{ | ||
* field: 'amountInEur', | ||
* operator: 'GreaterThan', | ||
* value: 1000 | ||
* }, { | ||
* field: 'description', | ||
* operator: 'Contains', | ||
* value: 'Refund', | ||
* }], | ||
* page: { limit: 10, skip: 0 }, | ||
* sort: [{ field: 'id', ascending: true }] | ||
* } | ||
* }, ['id', 'amountInEur', 'description']); | ||
*/ | ||
list(filter, projection) { | ||
@@ -38,2 +87,15 @@ const filterInstance = this.buildPaginatedFilter(filter); | ||
} | ||
/** | ||
* Update a list of records | ||
* @param filter the filter that represent the list of records to update | ||
* @param patch the patch to apply on the selected records | ||
* @example | ||
* .update({ | ||
* conditionTree: { | ||
* field: 'isActive', | ||
* operator: 'Equal', | ||
* value: false | ||
* }, | ||
* }, { isActive: true }); | ||
*/ | ||
update(filter, patch) { | ||
@@ -43,2 +105,14 @@ const filterInstance = this.buildFilter(filter); | ||
} | ||
/** | ||
* Delete a list of records | ||
* @param filter the filter that represent the list of records to update | ||
* @example | ||
* .delete({ | ||
* conditionTree: { | ||
* field: 'isBlocked', | ||
* operator: 'Equal', | ||
* value: false, | ||
* }, | ||
* }); | ||
*/ | ||
delete(filter) { | ||
@@ -48,2 +122,20 @@ const filterInstance = this.buildFilter(filter); | ||
} | ||
/** | ||
* Aggregate a list of records | ||
* @param filter the filter used to list the records to aggregate | ||
* @param aggregation the aggregation to apply | ||
* @param limit the maximum number of result to return | ||
* @example | ||
* .aggregate({ | ||
* conditionTree: { | ||
* field: "user:company:id", | ||
* operator: "In", | ||
* value: records.map((r) => r.id), | ||
* }, | ||
* }, { | ||
* operation: "Sum", | ||
* field: "amountInEur", | ||
* groups: [{ field: "user:company:id" }], | ||
* }, 10); | ||
*/ | ||
aggregate(filter, aggregation, limit) { | ||
@@ -82,2 +174,2 @@ const filterInstance = this.buildFilter(filter); | ||
exports.default = RelaxedCollection; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGVjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb250ZXh0L3JlbGF4ZWQtd3JhcHBlcnMvY29sbGVjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQVlBLHFGQUFvRztBQUNwRyw0RkFBaUY7QUFDakYsNEZBQWdGO0FBQ2hGLHVFQUErQztBQUMvQyx3RkFBZ0c7QUFDaEcsbUZBQTJEO0FBQzNELHVFQUErQztBQUUvQyxvRUFBb0U7QUFDcEUsTUFBcUIsaUJBQWlCO0lBT3BDLFlBQVksVUFBc0IsRUFBRSxNQUFjO1FBQ2hELElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDO1FBQzdCLElBQUksQ0FBQyxNQUFNLEdBQUcsTUFBTSxDQUFDO0lBQ3ZCLENBQUM7SUFFRCxPQUFPLENBQUMsSUFBWSxFQUFFLFVBQXNCLEVBQUUsTUFBMEI7UUFDdEUsTUFBTSxjQUFjL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NLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVM7WUFDeEQsSUFBSSxFQUFFLE1BQU0sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLElBQUksY0FBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLE1BQU0sQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUFDLFNBQVM7U0FDOUUsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztJQUVPLGVBQWUsQ0FBQyxVQUFvQjtRQUMxQyxPQUFPLElBQUksb0JBQVUsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxDQUFDO0lBQ3ZDLENBQUM7SUFFTyxnQkFBZ0IsQ0FBQyxXQUFtQztRQUMxRCxPQUFPLElBQUkscUJBQVcsQ0FBQyxXQUFXLENBQUMsQ0FBQztJQUN0QyxDQUFDO0NBQ0Y7QUF4TEQsb0NBd0xDIn0= |
@@ -10,4 +10,8 @@ import { Caller } from '../../interfaces/caller'; | ||
constructor(dataSource: DataSource, caller: Caller); | ||
/** | ||
* Get a collection from a datasource | ||
* @param name the name of the collection | ||
*/ | ||
getCollection<N extends TCollectionName<S>>(name: N): RelaxedCollection<S, N>; | ||
} | ||
//# sourceMappingURL=datasource.d.ts.map |
@@ -13,2 +13,6 @@ "use strict"; | ||
} | ||
/** | ||
* Get a collection from a datasource | ||
* @param name the name of the collection | ||
*/ | ||
getCollection(name) { | ||
@@ -19,2 +23,2 @@ return new collection_1.default(this.dataSource.getCollection(name), this.caller); | ||
exports.default = RelaxedDataSource; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YXNvdXJjZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb250ZXh0L3JlbGF4ZWQtd3JhcHBlcnMvZGF0YXNvdXJjZS50cyJdLCJuYW1l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Y7QUFoQkQsb0NBZ0JDIn0= |
@@ -13,4 +13,16 @@ import { Caller } from '../../../interfaces/caller'; | ||
constructor(collection: Collection, caller: Caller, formValue: RecordData, filter: PlainFilter<S, N>, used?: Set<string>); | ||
/** | ||
* Get all the records selected by an action | ||
* @param fields An array of fields needed in the response | ||
* @example | ||
* .getRecords(['id', 'isActive', 'name']); | ||
*/ | ||
getRecords(fields: TFieldName<S, N>[]): Promise<TRow<S, N>[]>; | ||
/** | ||
* Get all the records ids selected by an action | ||
*/ | ||
getRecordIds(): Promise<Array<string | number>>; | ||
/** | ||
* Get all the records ids (when the collection uses composite keys) | ||
*/ | ||
getCompositeRecordIds(): Promise<CompositeId[]>; | ||
@@ -17,0 +29,0 @@ private runQuery; |
@@ -31,2 +31,8 @@ "use strict"; | ||
} | ||
/** | ||
* Get all the records selected by an action | ||
* @param fields An array of fields needed in the response | ||
* @example | ||
* .getRecords(['id', 'isActive', 'name']); | ||
*/ | ||
async getRecords(fields) { | ||
@@ -53,2 +59,5 @@ // This function just queues the request into this.queries, so that we can merge all calls | ||
} | ||
/** | ||
* Get all the records ids selected by an action | ||
*/ | ||
async getRecordIds() { | ||
@@ -58,2 +67,5 @@ const compositeIds = await this.getCompositeRecordIds(); | ||
} | ||
/** | ||
* Get all the records ids (when the collection uses composite keys) | ||
*/ | ||
async getCompositeRecordIds() { | ||
@@ -90,2 +102,2 @@ const projection = new projection_1.default().withPks(this.realCollection); | ||
exports.default = ActionContext; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9kZWNvcmF0b3JzL2FjdGlvbnMvY29udGV4dC9iYXNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7O0FBS0EsNkZBQWlGO0FBQ2pGLGlFQUE0QztBQUM1QyxzRkFBOEQ7QUFDO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UsS0FBSyxNQUFNLEtBQUssSUFBSSxPQUFPO2dCQUFFLEtBQUssQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDLEtBQUssQ0FBQyxVQUFVLENBQUMsS0FBSyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7U0FDdEY7UUFBQyxPQUFPLENBQUMsRUFBRTtZQUNWLHVDQUF1QztZQUV2Qyx1RkFBdUY7WUFDdkYseUJBQXlCO1lBQ3pCLEtBQUssTUFBTSxLQUFLLElBQUksT0FBTyxFQUFFO2dCQUMzQixPQUFPLENBQUMsUUFBUSxDQUFDLEdBQUcsRUFBRSxDQUFDLEtBQUssQ0FBQyxRQUFRLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUM7YUFDbEQ7U0FDRjtJQUNILENBQUM7SUFFTyxLQUFLO1FBQ1gsSUFBSSxDQUFDLE9BQU8sR0FBRyxFQUFFLENBQUM7UUFDbEIsSUFBSSxDQUFDLFVBQVUsR0FBRyxJQUFJLG9CQUFVLEVBQUUsQ0FBQztJQUNyQyxDQUFDO0NBQ0Y7QUF0SEQsZ0NBc0hDIn0= |
@@ -5,2 +5,9 @@ /// <reference types="node" /> | ||
export default class ResultBuilder { | ||
/** | ||
* Returns a success response from the action | ||
* @param message the success message to return | ||
* @param options available options to return | ||
* @example | ||
* .success('<blinkee>Success!</blinkee>', { type: 'html' }); | ||
*/ | ||
success(message?: string, options?: { | ||
@@ -10,7 +17,36 @@ type?: 'html' | 'text'; | ||
}): ActionResult; | ||
/** | ||
* Returns an error response from the action | ||
* @param message the error message to return | ||
* @example | ||
* .error('Failed to refund the customer!'); | ||
*/ | ||
error(message?: string): ActionResult; | ||
/** | ||
* Returns a webhook that the UI will trigger | ||
* @param url the url of the webhook | ||
* @param method the HTTP method of the webhook | ||
* @param headers an object representing the list of headers to send with the webhook | ||
* @param body an object representing the body of the HTTP request | ||
* @example | ||
* .webhook('http://my-company-name', 'POST', {}, { adminToken: 'my-admin-token' }); | ||
*/ | ||
webhook(url: string, method?: 'GET' | 'POST', headers?: Record<string, string>, body?: unknown): ActionResult; | ||
/** | ||
* Returns a file that will be downloaded | ||
* @param streamOrBufferOrString the actual file to download | ||
* @param name the name of the file | ||
* @param mimeType the mime type of the file | ||
* @example | ||
* .file('This is my file content', 'download.txt', 'text/plain'); | ||
*/ | ||
file(streamOrBufferOrString: Readable | Uint8Array | string, name?: string, mimeType?: string): ActionResult; | ||
/** | ||
* Returns to the UI that a redirection is needed | ||
* @param path the path to redirect to | ||
* @example | ||
* .redirectTo('https://www.google.com'); | ||
*/ | ||
redirectTo(path: string): ActionResult; | ||
} | ||
//# sourceMappingURL=result-builder.d.ts.map |
@@ -5,2 +5,9 @@ "use strict"; | ||
class ResultBuilder { | ||
/** | ||
* Returns a success response from the action | ||
* @param message the success message to return | ||
* @param options available options to return | ||
* @example | ||
* .success('<blinkee>Success!</blinkee>', { type: 'html' }); | ||
*/ | ||
success(message, options) { | ||
@@ -14,2 +21,8 @@ return { | ||
} | ||
/** | ||
* Returns an error response from the action | ||
* @param message the error message to return | ||
* @example | ||
* .error('Failed to refund the customer!'); | ||
*/ | ||
error(message) { | ||
@@ -21,2 +34,11 @@ return { | ||
} | ||
/** | ||
* Returns a webhook that the UI will trigger | ||
* @param url the url of the webhook | ||
* @param method the HTTP method of the webhook | ||
* @param headers an object representing the list of headers to send with the webhook | ||
* @param body an object representing the body of the HTTP request | ||
* @example | ||
* .webhook('http://my-company-name', 'POST', {}, { adminToken: 'my-admin-token' }); | ||
*/ | ||
webhook(url, method = 'POST', headers = {}, body = {}) { | ||
@@ -31,2 +53,10 @@ return { | ||
} | ||
/** | ||
* Returns a file that will be downloaded | ||
* @param streamOrBufferOrString the actual file to download | ||
* @param name the name of the file | ||
* @param mimeType the mime type of the file | ||
* @example | ||
* .file('This is my file content', 'download.txt', 'text/plain'); | ||
*/ | ||
file(streamOrBufferOrString, name = 'file', mimeType = 'application/octet-stream') { | ||
@@ -42,2 +72,8 @@ return { | ||
} | ||
/** | ||
* Returns to the UI that a redirection is needed | ||
* @param path the path to redirect to | ||
* @example | ||
* .redirectTo('https://www.google.com'); | ||
*/ | ||
redirectTo(path) { | ||
@@ -48,2 +84,2 @@ return { type: 'Redirect', path }; | ||
exports.default = ResultBuilder; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVzdWx0LWJ1aWxkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvZGVjb3JhdG9ycy9hY3Rpb25zL3Jlc3VsdC1idWlsZGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsbUNBQWtDO0FBSWxDLE1BQXFCLGFBQWE7SUFDaEMsT0FBTyxDQUNMLE9BQWdCLEVBQ2hCLE9BQTREO1FBRTVELE9BQU87WUFDTCxJQUFJLEVBQUUsU0FBUztZQUNmLE9BQU8sRUFBRSxPQUFPLElBQUksU0FBUztZQUM3QixNQUFNLEVBQUUsT0FBTyxFQUFFLElBQUksSUFBSSxNQUFNO1lBQy9CLFdBQVcsRUFBRSxJQUFJLEdBQUcsQ0FBQyxPQUFPLEVBQUUsV0FBVyxJQUFJLEVBQUUsQ0FBQztTQUNqRCxDQUFDO0lBQ0osQ0FBQztJQUVELEtBQUssQ0FBQyxPQUFnQjtRQUNwQixPQUFPO1lBQ0wsSUFBSSxFQUFFLE9BQU87WUFDYixPQUFPLEVBQUUsT0FBTyxJQUFJLE9BQU87U0FDNUIsQ0FBQztJQUNKLENBQUM7SUFFRCxPQUFPLENBQ0wsR0FBVyxFQUNYLFNBQXlCLE1BQU0sRUFDL0IsVUFBa0MsRUFBRSxFQUNwQyxPQUFnQixFQUFFO1FBRWxCLE9BQU87WUFDTCxJQUFJLEVBQUUsU0FBUztZQUNmLEdBQUc7WUFDSCxNQUFNO1lBQ04sT0FBTztZQUNQLElBQUk7U0FDTCxDQUFDO0lBQ0osQ0FBQ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s7OztPQUtHO0lBQ0gsS0FBSyxDQUFDLE9BQWdCO1FBQ3BCLE9BQU87WUFDTCxJQUFJLEVBQUUsT0FBTztZQUNiLE9BQU8sRUFBRSxPQUFPLElBQUksT0FBTztTQUM1QixDQUFDO0lBQ0osQ0FBQztJQUVEOzs7Ozs7OztPQVFHO0lBQ0gsT0FBTyxDQUNMLEdBQVcsRUFDWCxTQUF5QixNQUFNLEVBQy9CLFVBQWtDLEVBQUUsRUFDcEMsT0FBZ0IsRUFBRTtRQUVsQixPQUFPO1lBQ0wsSUFBSSxFQUFFLFNBQVM7WUFDZixHQUFHO1lBQ0gsTUFBTTtZQUNOLE9BQU87WUFDUCxJQUFJO1NBQ0wsQ0FBQztJQUNKLENBQUM7SUFFRDs7Ozs7OztPQU9HO0lBQ0gsSUFBSSxDQUNGLHNCQUFzRCxFQUN0RCxJQUFJLEdBQUcsTUFBTSxFQUNiLFFBQVEsR0FBRywwQkFBMEI7UUFFckMsT0FBTztZQUNMLElBQUksRUFBRSxNQUFNO1lBQ1osSUFBSTtZQUNKLFFBQVE7WUFDUixNQUFNLEVBQ0osc0JBQXNCLFlBQVksaUJBQVE7Z0JBQ3hDLENBQUMsQ0FBQyxzQkFBc0I7Z0JBQ3hCLENBQUMsQ0FBQyxpQkFBUSxDQUFDLElBQUksQ0FBQyxDQUFDLHNCQUFzQixDQUFDLENBQUM7U0FDOUMsQ0FBQztJQUNKLENBQUM7SUFFRDs7Ozs7T0FLRztJQUNILFVBQVUsQ0FBQyxJQUFZO1FBQ3JCLE9BQU8sRUFBRSxJQUFJLEVBQUUsVUFBVSxFQUFFLElBQUksRUFBRSxDQUFDO0lBQ3BDLENBQUM7Q0FDRjtBQTFGRCxnQ0EwRkMifQ== |
@@ -7,3 +7,2 @@ import { ColumnType } from '../../interfaces/schema'; | ||
readonly dependencies: TFieldName<S, N>[]; | ||
readonly isRequired?: boolean; | ||
readonly defaultValue?: unknown; | ||
@@ -10,0 +9,0 @@ readonly enumValues?: string[]; |
{ | ||
"name": "@forestadmin/datasource-toolkit", | ||
"version": "1.0.0-beta.21", | ||
"version": "1.0.0-beta.22", | ||
"main": "dist/src/index.js", | ||
@@ -5,0 +5,0 @@ "license": "GPL-3.0", |
499749
5254