@forestadmin/datasource-customizer 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/collection-customizer.d.ts +263 -0
  2. package/dist/collection-customizer.js +397 -0
  3. package/dist/context/agent-context.d.ts +11 -0
  4. package/dist/context/agent-context.js +20 -0
  5. package/dist/context/collection-context.d.ts +10 -0
  6. package/dist/context/collection-context.js +18 -0
  7. package/dist/context/relaxed-wrappers/collection.d.ts +112 -0
  8. package/dist/context/relaxed-wrappers/collection.js +161 -0
  9. package/dist/context/relaxed-wrappers/datasource.d.ts +15 -0
  10. package/dist/context/relaxed-wrappers/datasource.js +22 -0
  11. package/dist/datasource-customizer.d.ts +53 -0
  12. package/dist/datasource-customizer.js +98 -0
  13. package/dist/decorators/actions/collection.d.ts +18 -0
  14. package/dist/decorators/actions/collection.js +104 -0
  15. package/dist/decorators/actions/context/base.d.ts +28 -0
  16. package/dist/decorators/actions/context/base.js +105 -0
  17. package/dist/decorators/actions/context/single.d.ts +9 -0
  18. package/dist/decorators/actions/context/single.js +22 -0
  19. package/dist/decorators/actions/result-builder.d.ts +53 -0
  20. package/dist/decorators/actions/result-builder.js +81 -0
  21. package/dist/decorators/actions/types/actions.d.ts +18 -0
  22. package/dist/decorators/actions/types/actions.js +11 -0
  23. package/dist/decorators/actions/types/fields.d.ts +32 -0
  24. package/dist/decorators/actions/types/fields.js +3 -0
  25. package/dist/decorators/chart/datasource.d.ts +11 -0
  26. package/dist/decorators/chart/datasource.js +38 -0
  27. package/dist/decorators/chart/result-builder.d.ts +12 -0
  28. package/dist/decorators/chart/result-builder.js +48 -0
  29. package/dist/decorators/chart/types.d.ts +6 -0
  30. package/dist/decorators/chart/types.js +3 -0
  31. package/dist/decorators/collection-decorator.d.ts +21 -0
  32. package/dist/decorators/collection-decorator.js +57 -0
  33. package/dist/decorators/composite-datasource.d.ts +11 -0
  34. package/dist/decorators/composite-datasource.js +38 -0
  35. package/dist/decorators/computed/collection.d.ts +14 -0
  36. package/dist/decorators/computed/collection.js +69 -0
  37. package/dist/decorators/computed/helpers/compute-fields.d.ts +5 -0
  38. package/dist/decorators/computed/helpers/compute-fields.js +36 -0
  39. package/dist/decorators/computed/helpers/rewrite-projection.d.ts +4 -0
  40. package/dist/decorators/computed/helpers/rewrite-projection.js +22 -0
  41. package/dist/decorators/computed/types.d.ts +11 -0
  42. package/dist/decorators/computed/types.js +3 -0
  43. package/dist/decorators/computed/utils/deduplication.d.ts +2 -0
  44. package/dist/decorators/computed/utils/deduplication.js +28 -0
  45. package/dist/decorators/computed/utils/flattener.d.ts +6 -0
  46. package/dist/decorators/computed/utils/flattener.js +35 -0
  47. package/dist/decorators/datasource-decorator.d.ts +15 -0
  48. package/dist/decorators/datasource-decorator.js +27 -0
  49. package/dist/decorators/decorators-stack.d.ts +42 -0
  50. package/dist/decorators/decorators-stack.js +59 -0
  51. package/dist/decorators/empty/collection.d.ts +18 -0
  52. package/dist/decorators/empty/collection.js +85 -0
  53. package/dist/decorators/hook/collection.d.ts +13 -0
  54. package/dist/decorators/hook/collection.js +67 -0
  55. package/dist/decorators/hook/context/aggregate.d.ts +22 -0
  56. package/dist/decorators/hook/context/aggregate.js +46 -0
  57. package/dist/decorators/hook/context/create.d.ts +17 -0
  58. package/dist/decorators/hook/context/create.js +35 -0
  59. package/dist/decorators/hook/context/delete.d.ts +14 -0
  60. package/dist/decorators/hook/context/delete.js +28 -0
  61. package/dist/decorators/hook/context/hook.d.ts +26 -0
  62. package/dist/decorators/hook/context/hook.js +38 -0
  63. package/dist/decorators/hook/context/list.d.ts +20 -0
  64. package/dist/decorators/hook/context/list.js +42 -0
  65. package/dist/decorators/hook/context/update.d.ts +16 -0
  66. package/dist/decorators/hook/context/update.js +31 -0
  67. package/dist/decorators/hook/hook.d.ts +10 -0
  68. package/dist/decorators/hook/hook.js +30 -0
  69. package/dist/decorators/hook/types.d.ts +28 -0
  70. package/dist/decorators/hook/types.js +24 -0
  71. package/dist/decorators/operators-emulate/collection.d.ts +15 -0
  72. package/dist/decorators/operators-emulate/collection.js +99 -0
  73. package/dist/decorators/operators-emulate/types.d.ts +4 -0
  74. package/dist/decorators/operators-emulate/types.js +3 -0
  75. package/dist/decorators/operators-replace/collection.d.ts +10 -0
  76. package/dist/decorators/operators-replace/collection.js +35 -0
  77. package/dist/decorators/publication-collection/datasource.d.ts +9 -0
  78. package/dist/decorators/publication-collection/datasource.js +43 -0
  79. package/dist/decorators/publication-field/collection.d.ts +14 -0
  80. package/dist/decorators/publication-field/collection.js +63 -0
  81. package/dist/decorators/relation/collection.d.ts +23 -0
  82. package/dist/decorators/relation/collection.js +190 -0
  83. package/dist/decorators/relation/types.d.ts +5 -0
  84. package/dist/decorators/relation/types.js +3 -0
  85. package/dist/decorators/rename-collection/collection.d.ts +15 -0
  86. package/dist/decorators/rename-collection/collection.js +50 -0
  87. package/dist/decorators/rename-collection/datasource.d.ts +11 -0
  88. package/dist/decorators/rename-collection/datasource.js +33 -0
  89. package/dist/decorators/rename-field/collection.d.ts +33 -0
  90. package/dist/decorators/rename-field/collection.js +149 -0
  91. package/dist/decorators/schema/collection.d.ts +13 -0
  92. package/dist/decorators/schema/collection.js +26 -0
  93. package/dist/decorators/search/collection.d.ts +14 -0
  94. package/dist/decorators/search/collection.js +105 -0
  95. package/dist/decorators/search/types.d.ts +4 -0
  96. package/dist/decorators/search/types.js +3 -0
  97. package/dist/decorators/segment/collection.d.ts +10 -0
  98. package/dist/decorators/segment/collection.js +43 -0
  99. package/dist/decorators/segment/types.d.ts +4 -0
  100. package/dist/decorators/segment/types.js +3 -0
  101. package/dist/decorators/sort-emulate/collection.d.ts +15 -0
  102. package/dist/decorators/sort-emulate/collection.js +97 -0
  103. package/dist/decorators/validation/collection.d.ts +20 -0
  104. package/dist/decorators/validation/collection.js +109 -0
  105. package/dist/decorators/write/collection.d.ts +26 -0
  106. package/dist/decorators/write/collection.js +214 -0
  107. package/dist/decorators/write/context.d.ts +9 -0
  108. package/dist/decorators/write/context.js +15 -0
  109. package/dist/decorators/write/types.d.ts +4 -0
  110. package/dist/decorators/write/types.js +3 -0
  111. package/dist/index.d.ts +14 -2
  112. package/dist/index.js +31 -2
  113. package/dist/templates.d.ts +65 -0
  114. package/dist/templates.js +3 -0
  115. package/dist/types.d.ts +20 -0
  116. package/dist/types.js +3 -0
  117. package/dist/typing-generator.d.ts +19 -0
  118. package/dist/typing-generator.js +123 -0
  119. package/package.json +2 -2
@@ -0,0 +1,263 @@
1
+ import { Operator } from '@forestadmin/datasource-toolkit';
2
+ import { ActionDefinition } from './decorators/actions/types/actions';
3
+ import { FieldDefinition, OneToManyEmbeddedDefinition } from './types';
4
+ import { HookHandler, HookPosition, HookType, HooksContext } from './decorators/hook/types';
5
+ import { OperatorDefinition } from './decorators/operators-emulate/types';
6
+ import { SearchDefinition } from './decorators/search/types';
7
+ import { SegmentDefinition } from './decorators/segment/types';
8
+ import { TCollectionName, TColumnName, TFieldName, TSchema, TSortClause } from './templates';
9
+ import { WriteDefinition } from './decorators/write/types';
10
+ import DecoratorsStack from './decorators/decorators-stack';
11
+ export default class CollectionCustomizer<S extends TSchema = TSchema, N extends TCollectionName<S> = TCollectionName<S>> {
12
+ private readonly name;
13
+ private readonly stack;
14
+ constructor(stack: DecoratorsStack, name: string);
15
+ /**
16
+ * Disable count in list view pagination for improved performance.
17
+ *
18
+ * @example
19
+ * .disableCount()
20
+ */
21
+ disableCount(): this;
22
+ /**
23
+ * Import a field from a many to one or one to one relation.
24
+ *
25
+ * @param name the name of the field that will be created on the collection
26
+ * @param options options to import the field
27
+ * @example
28
+ * .importField('authorName', { path: 'author:fullName' })
29
+ */
30
+ importField(name: string, options: {
31
+ path: TFieldName<S, N>;
32
+ beforeRelations?: boolean;
33
+ readonly?: boolean;
34
+ }): this;
35
+ /**
36
+ * Allow to rename a field of a given collection.
37
+ * @param oldName the current name of the field in a given collection
38
+ * @param newName the new name of the field
39
+ * @example
40
+ * .renameField('theCurrentNameOfTheField', 'theNewNameOfTheField');
41
+ */
42
+ renameField(oldName: TColumnName<S, N>, newName: string): this;
43
+ /**
44
+ * Remove field by setting its visibility to false.
45
+ * @param names the fields to remove
46
+ * @example
47
+ * .removeField('aFieldToRemove', 'anotherFieldToRemove');
48
+ */
49
+ removeField(...names: TColumnName<S, N>[]): this;
50
+ /**
51
+ * Add a new action on the collection.
52
+ * @param name the name of the action
53
+ * @param definition the definition of the action
54
+ * @example
55
+ * .addAction('is live', {
56
+ * scope: 'Single',
57
+ * execute: async (context, resultBuilder) => {
58
+ * return resultBuilder.success('Is live!');
59
+ * },
60
+ * })
61
+ */
62
+ addAction(name: string, definition: ActionDefinition<S, N>): this;
63
+ /**
64
+ * Add a new field on the collection.
65
+ * @param name the name of the field
66
+ * @param definition The definition of the field
67
+ * @example
68
+ * .addField('fullName', {
69
+ * columnType: 'String',
70
+ * dependencies: ['firstName', 'lastName'],
71
+ * getValues: (records) => records.map(record => \`${record.lastName} ${record.firstName}\`),
72
+ * });
73
+ */
74
+ addField(name: string, definition: FieldDefinition<S, N>): this;
75
+ /**
76
+ * Add a new validator to the edition form of a given field
77
+ * @param name The name of the field
78
+ * @param operator The validator that you wish to add
79
+ * @param value A configuration value that the validator may need
80
+ * @example
81
+ * .addFieldValidation('firstName', 'LongerThan', 2);
82
+ */
83
+ addFieldValidation(name: TColumnName<S, N>, operator: Operator, value?: unknown): this;
84
+ /**
85
+ * Add a many to one relation to the collection
86
+ * @param name name of the new relation
87
+ * @param foreignCollection name of the targeted collection
88
+ * @param options extra information about the relation
89
+ * @example
90
+ * books.addManyToOneRelation('myAuthor', 'persons', { foreignKey: 'authorId' })
91
+ */
92
+ addManyToOneRelation<T extends TCollectionName<S>>(name: string, foreignCollection: T, options: {
93
+ foreignKey: TColumnName<S, N>;
94
+ foreignKeyTarget?: TColumnName<S, T>;
95
+ }): this;
96
+ /**
97
+ * Add a one to many relation to the collection
98
+ * @param name name of the new relation
99
+ * @param foreignCollection name of the targeted collection
100
+ * @param options extra information about the relation
101
+ * @example
102
+ * persons.addOneToManyRelation('writtenBooks', 'books', { originKey: 'authorId' })
103
+ */
104
+ addOneToManyRelation<T extends TCollectionName<S>>(name: string, foreignCollection: T, options: {
105
+ originKey: TColumnName<S, T>;
106
+ originKeyTarget?: TColumnName<S, N>;
107
+ }): this;
108
+ /**
109
+ * Add a one to one relation to the collection
110
+ * @param name name of the new relation
111
+ * @param foreignCollection name of the targeted collection
112
+ * @param options extra information about the relation
113
+ * @example
114
+ * persons.addOneToOneRelation('bestFriend', 'persons', { originKey: 'bestFriendId' })
115
+ */
116
+ addOneToOneRelation<T extends TCollectionName<S>>(name: string, foreignCollection: T, options: {
117
+ originKey: TColumnName<S, T>;
118
+ originKeyTarget?: TColumnName<S, N>;
119
+ }): this;
120
+ /**
121
+ * Add a many to many relation to the collection
122
+ * @param name name of the new relation
123
+ * @param foreignCollection name of the targeted collection
124
+ * @param throughCollection name of the intermediary collection
125
+ * @param options extra information about the relation
126
+ * @example
127
+ * dvds.addManyToManyRelation('rentalsOfThisDvd', 'rentals', 'dvdRentals', {
128
+ * originKey: 'dvdId',
129
+ * foreignKey: 'rentalId'
130
+ * })
131
+ */
132
+ addManyToManyRelation<Foreign extends TCollectionName<S>, Through extends TCollectionName<S>>(name: string, foreignCollection: Foreign, throughCollection: Through, options: {
133
+ originKey: TColumnName<S, Through>;
134
+ foreignKey: TColumnName<S, Through>;
135
+ originKeyTarget?: TColumnName<S, N>;
136
+ foreignKeyTarget?: TColumnName<S, Foreign>;
137
+ }): this;
138
+ /**
139
+ * Add a virtual collection into the related data of a record.
140
+ *
141
+ * @param name name of the relation
142
+ * @param definition the definition of the new relation
143
+ * @example
144
+ * .addExternalRelation('states', {
145
+ * schema: { code: 'Number', name: 'String' },
146
+ * listRecords: ({ id }) => {
147
+ * return record.id == 34 ?
148
+ * [{ code: 'AL', name: 'Alabama' }, { code: 'AK', name: 'Alaska' }] :
149
+ * [{ code: 'AZ', name: 'Arizona' }, { code: 'TX', name: 'Texas' }];
150
+ * }
151
+ * })
152
+ */
153
+ addExternalRelation(name: string, definition: OneToManyEmbeddedDefinition<S, N>): this;
154
+ /**
155
+ * Add a new segment on the collection.
156
+ * @param name the name of the segment
157
+ * @param definition a function used to generate a condition tree
158
+ * or a condition tree
159
+ * @example
160
+ * .addSegment(
161
+ * 'Wrote more than 2 books',
162
+ * { field: 'booksCount', operator: 'GreaterThan', value: 2 }
163
+ * );
164
+ */
165
+ addSegment(name: string, definition: SegmentDefinition<S, N>): this;
166
+ /**
167
+ * Enable sorting on a specific field using emulation.
168
+ * As for all the emulation method, the field sorting will be done in-memory.
169
+ * @param name the name of the field to enable emulation on
170
+ * @example
171
+ * .emulateFieldSorting('fullName');
172
+ */
173
+ emulateFieldSorting(name: TColumnName<S, N>): this;
174
+ /**
175
+ * Replace an implementation for the sorting.
176
+ * The field sorting will be done by the datasource.
177
+ * @param name the name of the field to enable sort
178
+ * @param equivalentSort the sort equivalent
179
+ * @example
180
+ * .replaceFieldSorting(
181
+ * 'fullName',
182
+ * [
183
+ * { field: 'firstName', ascending: true },
184
+ * { field: 'lastName', ascending: true },
185
+ * ]
186
+ * )
187
+ */
188
+ replaceFieldSorting(name: TColumnName<S, N>, equivalentSort: TSortClause<S, N>[]): this;
189
+ /**
190
+ * Enable filtering on a specific field using emulation.
191
+ * As for all the emulation method, the field filtering will be done in-memory.
192
+ * @param name the name of the field to enable emulation on
193
+ * @example
194
+ * .emulateFieldFiltering('aField');
195
+ */
196
+ emulateFieldFiltering(name: TColumnName<S, N>): this;
197
+ /**
198
+ * Enable filtering on a specific field with a specific operator using emulation.
199
+ * As for all the emulation method, the field filtering will be done in-memory.
200
+ * @param name the name of the field to enable emulation on
201
+ * @param operator the operator to emulate
202
+ * @example
203
+ * .emulateFieldOperator('aField', 'In');
204
+ */
205
+ emulateFieldOperator(name: TColumnName<S, N>, operator: Operator): this;
206
+ /**
207
+ * Replace an implementation for a specific operator on a specific field.
208
+ * The operator replacement will be done by the datasource.
209
+ * @param name the name of the field to filter on
210
+ * @param operator the operator to replace
211
+ * @param replacer the proposed implementation
212
+ * @example
213
+ * .replaceFieldOperator('fullName', 'Contains', (value) => {
214
+ * return {
215
+ * aggregator: 'Or',
216
+ * conditions: [{
217
+ * field: 'firstName',
218
+ * operator: 'Contains',
219
+ * value
220
+ * }, {
221
+ * field: 'lastName',
222
+ * operator: 'Contains',
223
+ * value
224
+ * }]
225
+ * }
226
+ * });
227
+ */
228
+ replaceFieldOperator<C extends TColumnName<S, N>>(name: C, operator: Operator, replacer: OperatorDefinition<S, N, C>): this;
229
+ /**
230
+ * Replace the write behavior of a field.
231
+ * @param name the name of the field
232
+ * @param definition the function or a value to represent the write behavior
233
+ * @example
234
+ * .replaceFieldWriting('fullName', fullName => {
235
+ * const [firstName, lastName] = fullName.split(' ');
236
+ * return { firstName, lastName };
237
+ * });
238
+ */
239
+ replaceFieldWriting<C extends TColumnName<S, N>>(name: C, definition: WriteDefinition<S, N, C>): this;
240
+ /**
241
+ * Replace the behavior of the search bar
242
+ * @param definition handler to describe the new behavior
243
+ * @example
244
+ * .replaceSearch(async (searchString) => {
245
+ * return { field: 'name', operator: 'Contains', value: searchString };
246
+ * });
247
+ */
248
+ replaceSearch(definition: SearchDefinition<S, N>): this;
249
+ addHook<P extends HookPosition, T extends HookType>(position: P, type: T, handler: HookHandler<HooksContext<S, N>[P][T]>): this;
250
+ /**
251
+ * Add a relation between two collections.
252
+ * @param name name of the new relation
253
+ * @param definition definition of the new relation
254
+ * @example
255
+ * .addRelation('author', {
256
+ * type: 'ManyToOne',
257
+ * foreignCollection: 'persons',
258
+ * foreignKey: 'authorId'
259
+ * });
260
+ */
261
+ private addRelation;
262
+ }
263
+ //# sourceMappingURL=collection-customizer.d.ts.map
@@ -0,0 +1,397 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const datasource_toolkit_1 = require("@forestadmin/datasource-toolkit");
4
+ class CollectionCustomizer {
5
+ constructor(stack, name) {
6
+ this.name = name;
7
+ this.stack = stack;
8
+ }
9
+ /**
10
+ * Disable count in list view pagination for improved performance.
11
+ *
12
+ * @example
13
+ * .disableCount()
14
+ */
15
+ disableCount() {
16
+ this.stack.schema.getCollection(this.name).overrideSchema({ countable: false });
17
+ return this;
18
+ }
19
+ /**
20
+ * Import a field from a many to one or one to one relation.
21
+ *
22
+ * @param name the name of the field that will be created on the collection
23
+ * @param options options to import the field
24
+ * @example
25
+ * .importField('authorName', { path: 'author:fullName' })
26
+ */
27
+ importField(name, options) {
28
+ const collection = this.stack.lateComputed.getCollection(this.name);
29
+ const schema = datasource_toolkit_1.CollectionUtils.getFieldSchema(collection, options.path);
30
+ this.addField(name, {
31
+ beforeRelations: options.beforeRelations,
32
+ columnType: schema.columnType,
33
+ defaultValue: schema.defaultValue,
34
+ dependencies: [options.path],
35
+ getValues: records => records.map(r => datasource_toolkit_1.RecordUtils.getFieldValue(r, options.path)),
36
+ enumValues: schema.enumValues,
37
+ });
38
+ if (!schema.isReadOnly && !options.readonly) {
39
+ this.stack.write.getCollection(this.name).replaceFieldWriting(name, value => {
40
+ const path = options.path.split(':');
41
+ const writingPath = {};
42
+ path.reduce((nestedPath, currentPath, index) => {
43
+ nestedPath[currentPath] = index === path.length - 1 ? value : {};
44
+ return nestedPath[currentPath];
45
+ }, writingPath);
46
+ return writingPath;
47
+ });
48
+ }
49
+ if (schema.isReadOnly && options.readonly === false) {
50
+ throw new Error(`Readonly option should not be false because the field "${options.path}" is not writable`);
51
+ }
52
+ for (const operator of schema.filterOperators) {
53
+ const handler = value => ({ field: options.path, operator, value });
54
+ this.replaceFieldOperator(name, operator, handler);
55
+ }
56
+ if (schema.isSortable) {
57
+ this.replaceFieldSorting(name, [
58
+ { field: options.path, ascending: true },
59
+ ]);
60
+ }
61
+ return this;
62
+ }
63
+ /**
64
+ * Allow to rename a field of a given collection.
65
+ * @param oldName the current name of the field in a given collection
66
+ * @param newName the new name of the field
67
+ * @example
68
+ * .renameField('theCurrentNameOfTheField', 'theNewNameOfTheField');
69
+ */
70
+ renameField(oldName, newName) {
71
+ this.stack.renameField.getCollection(this.name).renameField(oldName, newName);
72
+ return this;
73
+ }
74
+ /**
75
+ * Remove field by setting its visibility to false.
76
+ * @param names the fields to remove
77
+ * @example
78
+ * .removeField('aFieldToRemove', 'anotherFieldToRemove');
79
+ */
80
+ removeField(...names) {
81
+ const collection = this.stack.publication.getCollection(this.name);
82
+ for (const name of names)
83
+ collection.changeFieldVisibility(name, false);
84
+ return this;
85
+ }
86
+ /**
87
+ * Add a new action on the collection.
88
+ * @param name the name of the action
89
+ * @param definition the definition of the action
90
+ * @example
91
+ * .addAction('is live', {
92
+ * scope: 'Single',
93
+ * execute: async (context, resultBuilder) => {
94
+ * return resultBuilder.success('Is live!');
95
+ * },
96
+ * })
97
+ */
98
+ addAction(name, definition) {
99
+ this.stack.action
100
+ .getCollection(this.name)
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ .addAction(name, definition);
103
+ return this;
104
+ }
105
+ /**
106
+ * Add a new field on the collection.
107
+ * @param name the name of the field
108
+ * @param definition The definition of the field
109
+ * @example
110
+ * .addField('fullName', {
111
+ * columnType: 'String',
112
+ * dependencies: ['firstName', 'lastName'],
113
+ * getValues: (records) => records.map(record => \`${record.lastName} ${record.firstName}\`),
114
+ * });
115
+ */
116
+ addField(name, definition) {
117
+ const { beforeRelations, ...computedDefinition } = definition;
118
+ const collection = definition.beforeRelations
119
+ ? this.stack.earlyComputed.getCollection(this.name)
120
+ : this.stack.lateComputed.getCollection(this.name);
121
+ collection.registerComputed(name, computedDefinition);
122
+ return this;
123
+ }
124
+ /**
125
+ * Add a new validator to the edition form of a given field
126
+ * @param name The name of the field
127
+ * @param operator The validator that you wish to add
128
+ * @param value A configuration value that the validator may need
129
+ * @example
130
+ * .addFieldValidation('firstName', 'LongerThan', 2);
131
+ */
132
+ addFieldValidation(name, operator, value) {
133
+ this.stack.validation.getCollection(this.name).addValidation(name, { operator, value });
134
+ return this;
135
+ }
136
+ /**
137
+ * Add a many to one relation to the collection
138
+ * @param name name of the new relation
139
+ * @param foreignCollection name of the targeted collection
140
+ * @param options extra information about the relation
141
+ * @example
142
+ * books.addManyToOneRelation('myAuthor', 'persons', { foreignKey: 'authorId' })
143
+ */
144
+ addManyToOneRelation(name, foreignCollection, options) {
145
+ this.addRelation(name, {
146
+ type: 'ManyToOne',
147
+ foreignCollection,
148
+ foreignKey: options.foreignKey,
149
+ foreignKeyTarget: options.foreignKeyTarget,
150
+ });
151
+ return this;
152
+ }
153
+ /**
154
+ * Add a one to many relation to the collection
155
+ * @param name name of the new relation
156
+ * @param foreignCollection name of the targeted collection
157
+ * @param options extra information about the relation
158
+ * @example
159
+ * persons.addOneToManyRelation('writtenBooks', 'books', { originKey: 'authorId' })
160
+ */
161
+ addOneToManyRelation(name, foreignCollection, options) {
162
+ this.addRelation(name, {
163
+ type: 'OneToMany',
164
+ foreignCollection,
165
+ originKey: options.originKey,
166
+ originKeyTarget: options.originKeyTarget,
167
+ });
168
+ return this;
169
+ }
170
+ /**
171
+ * Add a one to one relation to the collection
172
+ * @param name name of the new relation
173
+ * @param foreignCollection name of the targeted collection
174
+ * @param options extra information about the relation
175
+ * @example
176
+ * persons.addOneToOneRelation('bestFriend', 'persons', { originKey: 'bestFriendId' })
177
+ */
178
+ addOneToOneRelation(name, foreignCollection, options) {
179
+ this.addRelation(name, {
180
+ type: 'OneToOne',
181
+ foreignCollection,
182
+ originKey: options.originKey,
183
+ originKeyTarget: options.originKeyTarget,
184
+ });
185
+ return this;
186
+ }
187
+ /**
188
+ * Add a many to many relation to the collection
189
+ * @param name name of the new relation
190
+ * @param foreignCollection name of the targeted collection
191
+ * @param throughCollection name of the intermediary collection
192
+ * @param options extra information about the relation
193
+ * @example
194
+ * dvds.addManyToManyRelation('rentalsOfThisDvd', 'rentals', 'dvdRentals', {
195
+ * originKey: 'dvdId',
196
+ * foreignKey: 'rentalId'
197
+ * })
198
+ */
199
+ addManyToManyRelation(name, foreignCollection, throughCollection, options) {
200
+ this.addRelation(name, {
201
+ type: 'ManyToMany',
202
+ foreignCollection,
203
+ throughCollection,
204
+ originKey: options.originKey,
205
+ originKeyTarget: options.originKeyTarget,
206
+ foreignKey: options.foreignKey,
207
+ foreignKeyTarget: options.foreignKeyTarget,
208
+ });
209
+ return this;
210
+ }
211
+ /**
212
+ * Add a virtual collection into the related data of a record.
213
+ *
214
+ * @param name name of the relation
215
+ * @param definition the definition of the new relation
216
+ * @example
217
+ * .addExternalRelation('states', {
218
+ * schema: { code: 'Number', name: 'String' },
219
+ * listRecords: ({ id }) => {
220
+ * return record.id == 34 ?
221
+ * [{ code: 'AL', name: 'Alabama' }, { code: 'AK', name: 'Alaska' }] :
222
+ * [{ code: 'AZ', name: 'Arizona' }, { code: 'TX', name: 'Texas' }];
223
+ * }
224
+ * })
225
+ */
226
+ addExternalRelation(name, definition) {
227
+ const { schema } = this.stack.action.getCollection(this.name);
228
+ const primaryKeys = datasource_toolkit_1.SchemaUtils.getPrimaryKeys(schema);
229
+ return this.addField(name, {
230
+ dependencies: definition.dependencies ?? primaryKeys,
231
+ columnType: [definition.schema],
232
+ getValues: async (records, context) => Promise.all(records.map(async (record) => definition.listRecords(record, context))),
233
+ });
234
+ }
235
+ /**
236
+ * Add a new segment on the collection.
237
+ * @param name the name of the segment
238
+ * @param definition a function used to generate a condition tree
239
+ * or a condition tree
240
+ * @example
241
+ * .addSegment(
242
+ * 'Wrote more than 2 books',
243
+ * { field: 'booksCount', operator: 'GreaterThan', value: 2 }
244
+ * );
245
+ */
246
+ addSegment(name, definition) {
247
+ this.stack.segment.getCollection(this.name).addSegment(name, definition);
248
+ return this;
249
+ }
250
+ /**
251
+ * Enable sorting on a specific field using emulation.
252
+ * As for all the emulation method, the field sorting will be done in-memory.
253
+ * @param name the name of the field to enable emulation on
254
+ * @example
255
+ * .emulateFieldSorting('fullName');
256
+ */
257
+ emulateFieldSorting(name) {
258
+ this.stack.sortEmulate.getCollection(this.name).emulateFieldSorting(name);
259
+ return this;
260
+ }
261
+ /**
262
+ * Replace an implementation for the sorting.
263
+ * The field sorting will be done by the datasource.
264
+ * @param name the name of the field to enable sort
265
+ * @param equivalentSort the sort equivalent
266
+ * @example
267
+ * .replaceFieldSorting(
268
+ * 'fullName',
269
+ * [
270
+ * { field: 'firstName', ascending: true },
271
+ * { field: 'lastName', ascending: true },
272
+ * ]
273
+ * )
274
+ */
275
+ replaceFieldSorting(name, equivalentSort) {
276
+ this.stack.sortEmulate
277
+ .getCollection(this.name)
278
+ .replaceFieldSorting(name, equivalentSort);
279
+ return this;
280
+ }
281
+ /**
282
+ * Enable filtering on a specific field using emulation.
283
+ * As for all the emulation method, the field filtering will be done in-memory.
284
+ * @param name the name of the field to enable emulation on
285
+ * @example
286
+ * .emulateFieldFiltering('aField');
287
+ */
288
+ emulateFieldFiltering(name) {
289
+ const collection = this.stack.lateOpEmulate.getCollection(this.name);
290
+ const field = collection.schema.fields[name];
291
+ if (typeof field.columnType === 'string') {
292
+ const operators = datasource_toolkit_1.allowedOperatorsForColumnType[field.columnType];
293
+ for (const operator of operators) {
294
+ if (!field.filterOperators?.has(operator)) {
295
+ this.emulateFieldOperator(name, operator);
296
+ }
297
+ }
298
+ }
299
+ return this;
300
+ }
301
+ /**
302
+ * Enable filtering on a specific field with a specific operator using emulation.
303
+ * As for all the emulation method, the field filtering will be done in-memory.
304
+ * @param name the name of the field to enable emulation on
305
+ * @param operator the operator to emulate
306
+ * @example
307
+ * .emulateFieldOperator('aField', 'In');
308
+ */
309
+ emulateFieldOperator(name, operator) {
310
+ const collection = this.stack.earlyOpEmulate.getCollection(this.name).schema.fields[name]
311
+ ? this.stack.earlyOpEmulate.getCollection(this.name)
312
+ : this.stack.lateOpEmulate.getCollection(this.name);
313
+ collection.emulateFieldOperator(name, operator);
314
+ return this;
315
+ }
316
+ /**
317
+ * Replace an implementation for a specific operator on a specific field.
318
+ * The operator replacement will be done by the datasource.
319
+ * @param name the name of the field to filter on
320
+ * @param operator the operator to replace
321
+ * @param replacer the proposed implementation
322
+ * @example
323
+ * .replaceFieldOperator('fullName', 'Contains', (value) => {
324
+ * return {
325
+ * aggregator: 'Or',
326
+ * conditions: [{
327
+ * field: 'firstName',
328
+ * operator: 'Contains',
329
+ * value
330
+ * }, {
331
+ * field: 'lastName',
332
+ * operator: 'Contains',
333
+ * value
334
+ * }]
335
+ * }
336
+ * });
337
+ */
338
+ replaceFieldOperator(name, operator, replacer) {
339
+ const collection = this.stack.earlyOpEmulate.getCollection(this.name).schema.fields[name]
340
+ ? this.stack.earlyOpEmulate.getCollection(this.name)
341
+ : this.stack.lateOpEmulate.getCollection(this.name);
342
+ collection.replaceFieldOperator(name, operator, replacer);
343
+ return this;
344
+ }
345
+ /**
346
+ * Replace the write behavior of a field.
347
+ * @param name the name of the field
348
+ * @param definition the function or a value to represent the write behavior
349
+ * @example
350
+ * .replaceFieldWriting('fullName', fullName => {
351
+ * const [firstName, lastName] = fullName.split(' ');
352
+ * return { firstName, lastName };
353
+ * });
354
+ */
355
+ replaceFieldWriting(name, definition) {
356
+ this.stack.write.getCollection(this.name).replaceFieldWriting(name, definition);
357
+ return this;
358
+ }
359
+ /**
360
+ * Replace the behavior of the search bar
361
+ * @param definition handler to describe the new behavior
362
+ * @example
363
+ * .replaceSearch(async (searchString) => {
364
+ * return { field: 'name', operator: 'Contains', value: searchString };
365
+ * });
366
+ */
367
+ replaceSearch(definition) {
368
+ this.stack.search
369
+ .getCollection(this.name)
370
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
371
+ .replaceSearch(definition);
372
+ return this;
373
+ }
374
+ addHook(position, type, handler) {
375
+ this.stack.hook
376
+ .getCollection(this.name)
377
+ .addHook(position, type, handler);
378
+ return this;
379
+ }
380
+ /**
381
+ * Add a relation between two collections.
382
+ * @param name name of the new relation
383
+ * @param definition definition of the new relation
384
+ * @example
385
+ * .addRelation('author', {
386
+ * type: 'ManyToOne',
387
+ * foreignCollection: 'persons',
388
+ * foreignKey: 'authorId'
389
+ * });
390
+ */
391
+ addRelation(name, definition) {
392
+ this.stack.relation.getCollection(this.name).addRelation(name, definition);
393
+ return this;
394
+ }
395
+ }
396
+ exports.default = CollectionCustomizer;
397
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGVjdGlvbi1jdXN0b21pemVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2NvbGxlY3Rpb24tY3VzdG9taXplci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHdFQU95QztBQWF6QyxNQUFxQixvQkFBb0I7SUFPdkMsWUFBWSxLQUFzQixFQUFFLElBQVk7UUFDOUMsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7UUFDakIsSUFBSSxDQUFDLEtBQUssR0FBRyxLQUFLLENBQUM7SUFDckIsQ0FBQztJQUVEOzs7OztPQUtHO0lBQ0gsWUFBWTtRQUNWLElBQUksQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsY0FBYyxDQUFDLEVBQUUsU0FBUyxFQUFFLEtBQUssRUFBRSxDQUFDLENBQUM7UUFFaEYsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQ7Ozs7Ozs7T0FPRztJQUNILFdBQVcsQ0FDVCxJQUFZLEVBQ1osT0FBa0Y7UUFFbEYsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLEtBQUssQ0FBQyxZQUFZLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUNwRSxNQUFNLE1BQU0sR0FBRyxvQ0FBZSxDQUFDLGNBQWMsQ0FBQyxVQUFVLEVBQUUsT0FBTyxDQUFDLElBQUksQ0FBaUIsQ0FBQztRQUV4RixJQUFJLENBQUMsUU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xLQUFLLENBQUMsS0FBSyxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsbUJBQW1CLENBQUMsSUFBSSxFQUFFLFVBQVUsQ0FBQyxDQUFDO1FBRWhGLE9BQU8sSUFBSSxDQUFDO0lBQ2QsQ0FBQztJQUVEOzs7Ozs7O09BT0c7SUFDSCxhQUFhLENBQUMsVUFBa0M7UUFDOUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxNQUFNO2FBQ2QsYUFBYSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7WUFDekIsOERBQThEO2FBQzdELGFBQWEsQ0FBQyxVQUF3QyxDQUFDLENBQUM7UUFFM0QsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQsT0FBTyxDQUNMLFFBQVcsRUFDWCxJQUFPLEVBQ1AsT0FBOEM7UUFFOUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxJQUFJO2FBQ1osYUFBYSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUM7YUFDeEIsT0FBTyxDQUFDLFFBQVEsRUFBRSxJQUFJLEVBQUUsT0FBcUQsQ0FBQyxDQUFDO1FBRWxGLE9BQU8sSUFBSSxDQUFDO0lBQ2QsQ0FBQztJQUVEOzs7Ozs7Ozs7O09BVUc7SUFDSyxXQUFXLENBQUMsSUFBWSxFQUFFLFVBQThCO1FBQzlELElBQUksQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsV0FBVyxDQUFDLElBQUksRUFBRSxVQUFVLENBQUMsQ0FBQztRQUUzRSxPQUFPLElBQUksQ0FBQztJQUNkLENBQUM7Q0FDRjtBQS9lRCx1Q0ErZUMifQ==
@@ -0,0 +1,11 @@
1
+ import { Caller, DataSource } from '@forestadmin/datasource-toolkit';
2
+ import { TSchema } from '../templates';
3
+ import RelaxedDataSource from './relaxed-wrappers/datasource';
4
+ export default class AgentCustomizationContext<S extends TSchema = TSchema> {
5
+ private realDataSource;
6
+ private _caller;
7
+ get dataSource(): RelaxedDataSource<S>;
8
+ constructor(dataSource: DataSource, caller: Caller);
9
+ get caller(): Readonly<Caller>;
10
+ }
11
+ //# sourceMappingURL=agent-context.d.ts.map