@seliseblocks/client 0.1.0-beta.0

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.
@@ -0,0 +1,178 @@
1
+ import { BlocksHttpClient } from "../http/http-client.js";
2
+ import { BlocksDataCollection, BlocksDmsCreateFolderRequest, BlocksDmsListRequest, BlocksDmsUploadRequest, BlocksFileDeleteRequest, BlocksFileGetOptions, BlocksFileInfoListRequest, BlocksDataSchema, BlocksFileListRequest, BlocksFileUpdateAdditionalInfoRequest, BlocksFileUploadRequest, BlocksFolderDeleteRequest, BlocksGraphqlRequest, BlocksLocalStorageUploadRequest, BlocksPagedResult, BlocksRegexGenerateRequest, BlocksSchemaFieldValidationOptions, BlocksSchemaListOptions, BlocksSchemaValidationListOptions, BlocksUploadToUrlRequest } from "./types.js";
3
+ export declare class BlocksDataClient {
4
+ private readonly http;
5
+ constructor(http: BlocksHttpClient);
6
+ schemas: {
7
+ /**
8
+ * What: lists Data schemas through `GET /data/v4/schemas`.
9
+ * Why: runtime apps and form builders need to discover available collections/schema metadata.
10
+ * How: pass optional paging/filter fields; tenant routing always uses the `x-blocks-key` header, never `ProjectKey`.
11
+ */
12
+ list: (options?: BlocksSchemaListOptions) => Promise<BlocksPagedResult<BlocksDataSchema>>;
13
+ /**
14
+ * What: looks up one schema by name through `GET /data/v4/schemas`.
15
+ * Why: apps often need a compact schema lookup before rendering a single collection/form.
16
+ * How: pass the schema name; the SDK sends `SchemaName`, `PageNo=1`, and `PageSize=1`.
17
+ */
18
+ get: (schemaName: string) => Promise<BlocksPagedResult<BlocksDataSchema>>;
19
+ /**
20
+ * What: reads schema summary/aggregation through `GET /data/v4/schemas/aggregation`.
21
+ * Why: frontend admin/runtime dashboards may need schema list plus access-level summary in one response.
22
+ * How: pass the same list filters as `schemas.list`; the SDK does not send `ProjectKey`.
23
+ */
24
+ aggregation: (options?: BlocksSchemaListOptions) => Promise<unknown>;
25
+ /**
26
+ * What: reads one schema definition by id through `GET /data/v4/schemas/get-by-id`.
27
+ * Why: detail views need exact schema metadata when they already have the schema item id.
28
+ * How: pass the schema id; the SDK sends it as the `id` query parameter.
29
+ */
30
+ getById: (id: string) => Promise<unknown>;
31
+ /**
32
+ * What: reads general schema info through `GET /data/v4/schemas/info`.
33
+ * Why: generic runtime UIs can bootstrap schema metadata without naming a single schema.
34
+ * How: call after configuring `accessToken`; the SDK sends only auth plus `x-blocks-key`.
35
+ */
36
+ info: () => Promise<unknown>;
37
+ /**
38
+ * What: reads detailed schema info through `GET /data/v4/schemas/info-by-name`.
39
+ * Why: dynamic forms/tables need field-level metadata for one schema.
40
+ * How: pass the schema name; the SDK sends it as `schemaName`.
41
+ */
42
+ infoByName: (schemaName: string) => Promise<unknown>;
43
+ };
44
+ files: {
45
+ /**
46
+ * What: reads one file record through `GET /data/v4/Files/GetFile`.
47
+ * Why: frontend views need file metadata or a downloadable reference by file id.
48
+ * How: pass `fileId` and optional Data file configuration/version fields.
49
+ */
50
+ get: (fileId: string, options?: BlocksFileGetOptions) => Promise<unknown>;
51
+ /**
52
+ * What: batch-reads files through `POST /data/v4/Files/GetFiles`.
53
+ * Why: pages with many attachments should avoid one request per file.
54
+ * How: pass the file-list payload exactly as Data expects; the SDK does not inject project fields.
55
+ */
56
+ getMany: (request: BlocksFileListRequest) => Promise<unknown>;
57
+ /**
58
+ * What: lists file records and metadata through `POST /data/v4/Files/GetFilesInfo`.
59
+ * Why: storage browsers and attachment managers need paged file metadata before downloading content.
60
+ * How: pass paging, sort, and filter fields; the SDK sends your request without any `projectKey`.
61
+ */
62
+ info: (request: BlocksFileInfoListRequest) => Promise<unknown>;
63
+ /**
64
+ * What: requests an upload URL through `POST /data/v4/Files/GetPreSignedUrlForUpload`.
65
+ * Why: browser apps should upload binary content through the URL issued by Blocks Data.
66
+ * How: pass file metadata such as `name`, `contentType`, `configurationName`, and optional DMS fields.
67
+ */
68
+ presignedUploadUrl: (request: BlocksFileUploadRequest) => Promise<unknown>;
69
+ /**
70
+ * What: uploads binary content to a pre-signed storage URL.
71
+ * Why: the actual blob upload goes to cloud/object storage, not to the Blocks API host.
72
+ * How: pass the `uploadUrl` returned by `presignedUploadUrl` plus a `Blob`, stream, or buffer; this call sends no `x-blocks-key` or bearer token.
73
+ */
74
+ uploadToUrl: (request: BlocksUploadToUrlRequest) => Promise<unknown>;
75
+ /**
76
+ * What: uploads a file through `POST /data/v4/Files/UploadFileToLocalStorage`.
77
+ * Why: local-storage deployments need multipart upload through Blocks Data instead of a pre-signed cloud URL.
78
+ * How: pass a `Blob`/`File` and metadata; the SDK builds `FormData` and does not add `projectKey`.
79
+ */
80
+ uploadToLocalStorage: (request: BlocksLocalStorageUploadRequest) => Promise<unknown>;
81
+ /**
82
+ * What: deletes a file through `POST /data/v4/Files/DeleteFile`.
83
+ * Why: storage UIs need to remove files when permissions and Data rules allow it.
84
+ * How: pass `fileId` and optional `configurationName`; the SDK sends no project key.
85
+ */
86
+ delete: (request: BlocksFileDeleteRequest) => Promise<unknown>;
87
+ /**
88
+ * What: updates file additional properties through `POST /data/v4/Files/updateFileAdditionalInfo`.
89
+ * Why: apps often need to attach searchable metadata such as agent status or business references to a file.
90
+ * How: pass `itemId` and `additionalProperties`; the SDK forwards the request as-is except for not adding project fields.
91
+ */
92
+ updateAdditionalInfo: (request: BlocksFileUpdateAdditionalInfoRequest) => Promise<unknown>;
93
+ /**
94
+ * What: reads DMS file/folder entries through `POST /data/v4/Files/GetDmsFileAndFolder`.
95
+ * Why: document-management views need combined folder and file listings.
96
+ * How: pass Data's DMS listing payload exactly as your app builds it.
97
+ */
98
+ listFolder: (request: BlocksFileListRequest) => Promise<unknown>;
99
+ };
100
+ dms: {
101
+ /**
102
+ * What: lists DMS files and folders through `POST /data/v4/Files/GetDmsFileAndFolder`.
103
+ * Why: document-management screens need folder contents, search, skip/take paging, and file entries together.
104
+ * How: pass DMS listing fields such as `parentId`, `configurationName`, `searchKey`, `skip`, and `take`.
105
+ */
106
+ list: (request: BlocksDmsListRequest) => Promise<unknown>;
107
+ /**
108
+ * What: registers uploaded files in DMS through `POST /data/v4/Files/UploadFile`.
109
+ * Why: after binary upload, DMS needs artifact metadata so files appear in document folders.
110
+ * How: pass the `upload` array with file storage ids and metadata returned from the upload flow.
111
+ */
112
+ uploadFiles: (request: BlocksDmsUploadRequest) => Promise<unknown>;
113
+ /**
114
+ * What: creates a DMS folder through `POST /data/v4/Files/CreateFolder`.
115
+ * Why: document-management UIs need to create folder hierarchy for uploaded files.
116
+ * How: pass folder metadata such as `artifactName`, `parentId`, and optional `configurationName`.
117
+ */
118
+ createFolder: (request: BlocksDmsCreateFolderRequest) => Promise<unknown>;
119
+ /**
120
+ * What: deletes a DMS folder through `POST /data/v4/Files/DeleteFolder`.
121
+ * Why: document-management UIs need to remove empty or allowed folders.
122
+ * How: pass `folderId` and optional `configurationName`; the SDK sends no project key.
123
+ */
124
+ deleteFolder: (request: BlocksFolderDeleteRequest) => Promise<unknown>;
125
+ };
126
+ validations: {
127
+ /**
128
+ * What: lists field validation rules through `GET /data/v4/data-validations`.
129
+ * Why: dynamic forms can render backend validation rules for schema fields.
130
+ * How: pass optional schema/field/paging filters; the SDK does not send `ProjectKey`.
131
+ */
132
+ list: (options?: BlocksSchemaValidationListOptions) => Promise<unknown>;
133
+ /**
134
+ * What: reads one validation rule through `GET /data/v4/data-validations/get-by-id`.
135
+ * Why: validation detail screens need one rule by id.
136
+ * How: pass the validation id.
137
+ */
138
+ getById: (id: string) => Promise<unknown>;
139
+ /**
140
+ * What: reads all validations for a schema through `GET /data/v4/data-validations/by-schema-id`.
141
+ * Why: form builders and runtime renderers need the validation set for one schema.
142
+ * How: pass the schema id.
143
+ */
144
+ bySchemaId: (schemaId: string) => Promise<unknown>;
145
+ /**
146
+ * What: reads validation for one schema field through `GET /data/v4/data-validations/by-schema-and-field`.
147
+ * Why: field renderers can load rules lazily for a single field.
148
+ * How: pass `schemaId` and `fieldName`.
149
+ */
150
+ bySchemaAndField: (options: BlocksSchemaFieldValidationOptions) => Promise<unknown>;
151
+ };
152
+ /**
153
+ * What: executes a GraphQL operation through `POST /data/v4/gateway`.
154
+ * Why: the Data Gateway runtime exposes schema-backed collections through GraphQL with tenant-aware access controls.
155
+ * How: pass `query`, optional `variables`, optional `operationName`, and optional headers such as `x-graphql-playground`.
156
+ */
157
+ graphql(request: BlocksGraphqlRequest): Promise<unknown>;
158
+ utilities: {
159
+ /**
160
+ * What: generates a regex pattern through `POST /data/v4/regex/generate-regex`.
161
+ * Why: schema/form builders can ask Blocks Data for a validation regex suggestion.
162
+ * How: pass a text `description` and optional constraints; the SDK returns the generated pattern response.
163
+ */
164
+ generateRegex: (request: BlocksRegexGenerateRequest) => Promise<unknown>;
165
+ /**
166
+ * What: reads mock data through `GET /data/v4/mock-data`.
167
+ * Why: development/test UIs may need sample data exposed by Blocks Data.
168
+ * How: call with an authorized token; this is read-only and does not mutate stored mock data.
169
+ */
170
+ mockData: () => Promise<unknown>;
171
+ };
172
+ /**
173
+ * What: creates CRUD helpers for a Data runtime collection.
174
+ * Why: frontend code usually works with business collection names rather than hand-written URLs.
175
+ * How: pass the exact collection name; returned helpers support list/get/create/update/delete and never add `ProjectKey`.
176
+ */
177
+ collection<T = Record<string, unknown>>(name: string): BlocksDataCollection<T>;
178
+ }
@@ -0,0 +1,385 @@
1
+ const DATA_API = "/data/v4";
2
+ export class BlocksDataClient {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ schemas = {
8
+ /**
9
+ * What: lists Data schemas through `GET /data/v4/schemas`.
10
+ * Why: runtime apps and form builders need to discover available collections/schema metadata.
11
+ * How: pass optional paging/filter fields; tenant routing always uses the `x-blocks-key` header, never `ProjectKey`.
12
+ */
13
+ list: (options = {}) => this.http.request(`${DATA_API}/schemas`, {
14
+ query: schemaListQuery(options)
15
+ }),
16
+ /**
17
+ * What: looks up one schema by name through `GET /data/v4/schemas`.
18
+ * Why: apps often need a compact schema lookup before rendering a single collection/form.
19
+ * How: pass the schema name; the SDK sends `SchemaName`, `PageNo=1`, and `PageSize=1`.
20
+ */
21
+ get: (schemaName) => this.http.request(`${DATA_API}/schemas`, {
22
+ query: { PageNo: 1, PageSize: 1, SchemaName: schemaName }
23
+ }),
24
+ /**
25
+ * What: reads schema summary/aggregation through `GET /data/v4/schemas/aggregation`.
26
+ * Why: frontend admin/runtime dashboards may need schema list plus access-level summary in one response.
27
+ * How: pass the same list filters as `schemas.list`; the SDK does not send `ProjectKey`.
28
+ */
29
+ aggregation: (options = {}) => this.http.request(`${DATA_API}/schemas/aggregation`, {
30
+ query: schemaListQuery(options)
31
+ }),
32
+ /**
33
+ * What: reads one schema definition by id through `GET /data/v4/schemas/get-by-id`.
34
+ * Why: detail views need exact schema metadata when they already have the schema item id.
35
+ * How: pass the schema id; the SDK sends it as the `id` query parameter.
36
+ */
37
+ getById: (id) => this.http.request(`${DATA_API}/schemas/get-by-id`, {
38
+ query: { id }
39
+ }),
40
+ /**
41
+ * What: reads general schema info through `GET /data/v4/schemas/info`.
42
+ * Why: generic runtime UIs can bootstrap schema metadata without naming a single schema.
43
+ * How: call after configuring `accessToken`; the SDK sends only auth plus `x-blocks-key`.
44
+ */
45
+ info: () => this.http.request(`${DATA_API}/schemas/info`),
46
+ /**
47
+ * What: reads detailed schema info through `GET /data/v4/schemas/info-by-name`.
48
+ * Why: dynamic forms/tables need field-level metadata for one schema.
49
+ * How: pass the schema name; the SDK sends it as `schemaName`.
50
+ */
51
+ infoByName: (schemaName) => this.http.request(`${DATA_API}/schemas/info-by-name`, {
52
+ query: { schemaName }
53
+ })
54
+ };
55
+ files = {
56
+ /**
57
+ * What: reads one file record through `GET /data/v4/Files/GetFile`.
58
+ * Why: frontend views need file metadata or a downloadable reference by file id.
59
+ * How: pass `fileId` and optional Data file configuration/version fields.
60
+ */
61
+ get: (fileId, options = {}) => this.http.request(`${DATA_API}/Files/GetFile`, {
62
+ query: {
63
+ ConfigurationName: options.configurationName,
64
+ FileId: fileId,
65
+ Version: options.version
66
+ }
67
+ }),
68
+ /**
69
+ * What: batch-reads files through `POST /data/v4/Files/GetFiles`.
70
+ * Why: pages with many attachments should avoid one request per file.
71
+ * How: pass the file-list payload exactly as Data expects; the SDK does not inject project fields.
72
+ */
73
+ getMany: (request) => this.http.request(`${DATA_API}/Files/GetFiles`, {
74
+ body: normalizeFileListRequest(request)
75
+ }),
76
+ /**
77
+ * What: lists file records and metadata through `POST /data/v4/Files/GetFilesInfo`.
78
+ * Why: storage browsers and attachment managers need paged file metadata before downloading content.
79
+ * How: pass paging, sort, and filter fields; the SDK sends your request without any `projectKey`.
80
+ */
81
+ info: (request) => this.http.request(`${DATA_API}/Files/GetFilesInfo`, {
82
+ body: withoutProjectKey(request)
83
+ }),
84
+ /**
85
+ * What: requests an upload URL through `POST /data/v4/Files/GetPreSignedUrlForUpload`.
86
+ * Why: browser apps should upload binary content through the URL issued by Blocks Data.
87
+ * How: pass file metadata such as `name`, `contentType`, `configurationName`, and optional DMS fields.
88
+ */
89
+ presignedUploadUrl: (request) => this.http.request(`${DATA_API}/Files/GetPreSignedUrlForUpload`, {
90
+ body: normalizeUploadRequest(request)
91
+ }),
92
+ /**
93
+ * What: uploads binary content to a pre-signed storage URL.
94
+ * Why: the actual blob upload goes to cloud/object storage, not to the Blocks API host.
95
+ * How: pass the `uploadUrl` returned by `presignedUploadUrl` plus a `Blob`, stream, or buffer; this call sends no `x-blocks-key` or bearer token.
96
+ */
97
+ uploadToUrl: (request) => {
98
+ const headers = new Headers(request.headers);
99
+ if (request.contentType && !headers.has("Content-Type"))
100
+ headers.set("Content-Type", request.contentType);
101
+ if (!headers.has("x-ms-blob-type"))
102
+ headers.set("x-ms-blob-type", "Blockblob");
103
+ return this.http.external(request.url, {
104
+ body: request.body,
105
+ headers,
106
+ method: "PUT"
107
+ });
108
+ },
109
+ /**
110
+ * What: uploads a file through `POST /data/v4/Files/UploadFileToLocalStorage`.
111
+ * Why: local-storage deployments need multipart upload through Blocks Data instead of a pre-signed cloud URL.
112
+ * How: pass a `Blob`/`File` and metadata; the SDK builds `FormData` and does not add `projectKey`.
113
+ */
114
+ uploadToLocalStorage: (request) => this.http.request(`${DATA_API}/Files/UploadFileToLocalStorage`, {
115
+ body: toLocalStorageFormData(request),
116
+ headers: {}
117
+ }),
118
+ /**
119
+ * What: deletes a file through `POST /data/v4/Files/DeleteFile`.
120
+ * Why: storage UIs need to remove files when permissions and Data rules allow it.
121
+ * How: pass `fileId` and optional `configurationName`; the SDK sends no project key.
122
+ */
123
+ delete: (request) => this.http.request(`${DATA_API}/Files/DeleteFile`, {
124
+ body: withoutProjectKey(request)
125
+ }),
126
+ /**
127
+ * What: updates file additional properties through `POST /data/v4/Files/updateFileAdditionalInfo`.
128
+ * Why: apps often need to attach searchable metadata such as agent status or business references to a file.
129
+ * How: pass `itemId` and `additionalProperties`; the SDK forwards the request as-is except for not adding project fields.
130
+ */
131
+ updateAdditionalInfo: (request) => this.http.request(`${DATA_API}/Files/updateFileAdditionalInfo`, {
132
+ body: withoutProjectKey(request)
133
+ }),
134
+ /**
135
+ * What: reads DMS file/folder entries through `POST /data/v4/Files/GetDmsFileAndFolder`.
136
+ * Why: document-management views need combined folder and file listings.
137
+ * How: pass Data's DMS listing payload exactly as your app builds it.
138
+ */
139
+ listFolder: (request) => this.http.request(`${DATA_API}/Files/GetDmsFileAndFolder`, {
140
+ body: withoutProjectKey(request)
141
+ })
142
+ };
143
+ dms = {
144
+ /**
145
+ * What: lists DMS files and folders through `POST /data/v4/Files/GetDmsFileAndFolder`.
146
+ * Why: document-management screens need folder contents, search, skip/take paging, and file entries together.
147
+ * How: pass DMS listing fields such as `parentId`, `configurationName`, `searchKey`, `skip`, and `take`.
148
+ */
149
+ list: (request) => this.http.request(`${DATA_API}/Files/GetDmsFileAndFolder`, {
150
+ body: withoutProjectKey(request)
151
+ }),
152
+ /**
153
+ * What: registers uploaded files in DMS through `POST /data/v4/Files/UploadFile`.
154
+ * Why: after binary upload, DMS needs artifact metadata so files appear in document folders.
155
+ * How: pass the `upload` array with file storage ids and metadata returned from the upload flow.
156
+ */
157
+ uploadFiles: (request) => this.http.request(`${DATA_API}/Files/UploadFile`, {
158
+ body: withoutProjectKey(request)
159
+ }),
160
+ /**
161
+ * What: creates a DMS folder through `POST /data/v4/Files/CreateFolder`.
162
+ * Why: document-management UIs need to create folder hierarchy for uploaded files.
163
+ * How: pass folder metadata such as `artifactName`, `parentId`, and optional `configurationName`.
164
+ */
165
+ createFolder: (request) => this.http.request(`${DATA_API}/Files/CreateFolder`, {
166
+ body: withoutProjectKey(request)
167
+ }),
168
+ /**
169
+ * What: deletes a DMS folder through `POST /data/v4/Files/DeleteFolder`.
170
+ * Why: document-management UIs need to remove empty or allowed folders.
171
+ * How: pass `folderId` and optional `configurationName`; the SDK sends no project key.
172
+ */
173
+ deleteFolder: (request) => this.http.request(`${DATA_API}/Files/DeleteFolder`, {
174
+ body: withoutProjectKey(request)
175
+ })
176
+ };
177
+ validations = {
178
+ /**
179
+ * What: lists field validation rules through `GET /data/v4/data-validations`.
180
+ * Why: dynamic forms can render backend validation rules for schema fields.
181
+ * How: pass optional schema/field/paging filters; the SDK does not send `ProjectKey`.
182
+ */
183
+ list: (options = {}) => this.http.request(`${DATA_API}/data-validations`, {
184
+ query: validationListQuery(options)
185
+ }),
186
+ /**
187
+ * What: reads one validation rule through `GET /data/v4/data-validations/get-by-id`.
188
+ * Why: validation detail screens need one rule by id.
189
+ * How: pass the validation id.
190
+ */
191
+ getById: (id) => this.http.request(`${DATA_API}/data-validations/get-by-id`, {
192
+ query: { id }
193
+ }),
194
+ /**
195
+ * What: reads all validations for a schema through `GET /data/v4/data-validations/by-schema-id`.
196
+ * Why: form builders and runtime renderers need the validation set for one schema.
197
+ * How: pass the schema id.
198
+ */
199
+ bySchemaId: (schemaId) => this.http.request(`${DATA_API}/data-validations/by-schema-id`, {
200
+ query: { schemaId }
201
+ }),
202
+ /**
203
+ * What: reads validation for one schema field through `GET /data/v4/data-validations/by-schema-and-field`.
204
+ * Why: field renderers can load rules lazily for a single field.
205
+ * How: pass `schemaId` and `fieldName`.
206
+ */
207
+ bySchemaAndField: (options) => this.http.request(`${DATA_API}/data-validations/by-schema-and-field`, {
208
+ query: options
209
+ })
210
+ };
211
+ /**
212
+ * What: executes a GraphQL operation through `POST /data/v4/gateway`.
213
+ * Why: the Data Gateway runtime exposes schema-backed collections through GraphQL with tenant-aware access controls.
214
+ * How: pass `query`, optional `variables`, optional `operationName`, and optional headers such as `x-graphql-playground`.
215
+ */
216
+ graphql(request) {
217
+ return this.http.request(`${DATA_API}/gateway`, {
218
+ body: {
219
+ operationName: request.operationName,
220
+ query: request.query,
221
+ variables: request.variables
222
+ },
223
+ headers: request.headers
224
+ });
225
+ }
226
+ utilities = {
227
+ /**
228
+ * What: generates a regex pattern through `POST /data/v4/regex/generate-regex`.
229
+ * Why: schema/form builders can ask Blocks Data for a validation regex suggestion.
230
+ * How: pass a text `description` and optional constraints; the SDK returns the generated pattern response.
231
+ */
232
+ generateRegex: (request) => this.http.request(`${DATA_API}/regex/generate-regex`, {
233
+ body: request
234
+ }),
235
+ /**
236
+ * What: reads mock data through `GET /data/v4/mock-data`.
237
+ * Why: development/test UIs may need sample data exposed by Blocks Data.
238
+ * How: call with an authorized token; this is read-only and does not mutate stored mock data.
239
+ */
240
+ mockData: () => this.http.request(`${DATA_API}/mock-data`)
241
+ };
242
+ /**
243
+ * What: creates CRUD helpers for a Data runtime collection.
244
+ * Why: frontend code usually works with business collection names rather than hand-written URLs.
245
+ * How: pass the exact collection name; returned helpers support list/get/create/update/delete and never add `ProjectKey`.
246
+ */
247
+ collection(name) {
248
+ return {
249
+ /**
250
+ * What: creates a collection item through `POST /data/v4/{collection}`.
251
+ * Why: forms need a direct runtime create operation.
252
+ * How: pass the item payload; Data validates it against the active collection schema.
253
+ */
254
+ create: (payload) => this.http.request(`${DATA_API}/${encodeURIComponent(name)}`, { body: payload }),
255
+ /**
256
+ * What: deletes a collection item through `DELETE /data/v4/{collection}/{itemId}`.
257
+ * Why: collection UIs need a runtime delete operation when allowed by permissions/rules.
258
+ * How: pass the item id from Data.
259
+ */
260
+ delete: (itemId) => this.http.request(`${DATA_API}/${encodeURIComponent(name)}/${encodeURIComponent(itemId)}`, {
261
+ method: "DELETE"
262
+ }),
263
+ /**
264
+ * What: reads one collection item through `GET /data/v4/{collection}/{itemId}`.
265
+ * Why: detail pages need one runtime record by id.
266
+ * How: pass the item id from Data.
267
+ */
268
+ get: (itemId) => this.http.request(`${DATA_API}/${encodeURIComponent(name)}/${encodeURIComponent(itemId)}`),
269
+ /**
270
+ * What: lists collection items through `GET /data/v4/{collection}`.
271
+ * Why: tables, grids, and pickers need paged runtime records.
272
+ * How: pass `pageNo`, `pageSize`, and optional query fields supported by the collection endpoint.
273
+ */
274
+ list: (options) => this.http.request(`${DATA_API}/${encodeURIComponent(name)}`, {
275
+ query: {
276
+ PageNo: options?.pageNo ?? 1,
277
+ PageSize: options?.pageSize ?? 20,
278
+ ...options?.query
279
+ }
280
+ }),
281
+ /**
282
+ * What: updates a collection item through `PUT /data/v4/{collection}/{itemId}`.
283
+ * Why: edit forms need a runtime update operation.
284
+ * How: pass the item id and partial payload; Data applies its schema/rule validation.
285
+ */
286
+ update: (itemId, payload) => this.http.request(`${DATA_API}/${encodeURIComponent(name)}/${encodeURIComponent(itemId)}`, {
287
+ body: payload,
288
+ method: "PUT"
289
+ })
290
+ };
291
+ }
292
+ }
293
+ function normalizeFileListRequest(request) {
294
+ const record = withoutProjectKey(request);
295
+ if (request.fileIds && !record.FileIds)
296
+ record.FileIds = request.fileIds;
297
+ delete record.fileIds;
298
+ return record;
299
+ }
300
+ function schemaListQuery(options) {
301
+ return {
302
+ CollectionName: options.collectionName,
303
+ Keyword: options.keyword,
304
+ PageNo: options.pageNo ?? 1,
305
+ PageSize: options.pageSize ?? 100,
306
+ SchemaName: options.schemaName,
307
+ SchemaType: options.schemaType,
308
+ SortBy: options.sortBy,
309
+ SortDescending: options.sortDescending
310
+ };
311
+ }
312
+ function validationListQuery(options) {
313
+ return {
314
+ FieldName: options.fieldName,
315
+ Keyword: options.keyword,
316
+ PageNo: options.pageNo ?? 1,
317
+ PageSize: options.pageSize ?? 100,
318
+ SchemaId: options.schemaId,
319
+ SortBy: options.sortBy,
320
+ SortDescending: options.sortDescending
321
+ };
322
+ }
323
+ function normalizeUploadRequest(request) {
324
+ const record = withoutProjectKey(request);
325
+ if (request.fileName && !record.Name)
326
+ record.Name = request.fileName;
327
+ if (request.name && !record.Name)
328
+ record.Name = request.name;
329
+ if (request.itemId && !record.ItemId)
330
+ record.ItemId = request.itemId;
331
+ if (request.metaData && !record.MetaData)
332
+ record.MetaData = request.metaData;
333
+ if (request.parentDirectoryId && !record.ParentDirectoryId)
334
+ record.ParentDirectoryId = request.parentDirectoryId;
335
+ if (request.tags && !record.Tags)
336
+ record.Tags = request.tags;
337
+ if (request.accessModifier && !record.AccessModifier)
338
+ record.AccessModifier = request.accessModifier;
339
+ if (request.configurationName && !record.ConfigurationName)
340
+ record.ConfigurationName = request.configurationName;
341
+ if (request.moduleName !== undefined && !record.ModuleName)
342
+ record.ModuleName = request.moduleName;
343
+ if (request.additionalProperties && !record.AdditionalProperties)
344
+ record.AdditionalProperties = request.additionalProperties;
345
+ delete record.fileName;
346
+ delete record.contentType;
347
+ delete record.name;
348
+ delete record.itemId;
349
+ delete record.metaData;
350
+ delete record.parentDirectoryId;
351
+ delete record.tags;
352
+ delete record.accessModifier;
353
+ delete record.configurationName;
354
+ delete record.moduleName;
355
+ delete record.additionalProperties;
356
+ return record;
357
+ }
358
+ function toLocalStorageFormData(request) {
359
+ const form = new FormData();
360
+ appendFormValue(form, "File", request.file);
361
+ appendFormValue(form, "Name", request.name);
362
+ appendFormValue(form, "ItemId", request.itemId);
363
+ appendFormValue(form, "MetaData", request.metaData);
364
+ appendFormValue(form, "ParentDirectoryId", request.parentDirectoryId);
365
+ appendFormValue(form, "Tags", Array.isArray(request.tags) ? request.tags.join(",") : request.tags);
366
+ appendFormValue(form, "AccessModifier", request.accessModifier);
367
+ appendFormValue(form, "ConfigurationName", request.configurationName);
368
+ if (request.additionalProperties) {
369
+ for (const [key, value] of Object.entries(request.additionalProperties)) {
370
+ form.append(`AdditionalProperties[${key}]`, value);
371
+ }
372
+ }
373
+ return form;
374
+ }
375
+ function appendFormValue(form, key, value) {
376
+ if (value === undefined)
377
+ return;
378
+ form.append(key, value instanceof Blob ? value : String(value));
379
+ }
380
+ function withoutProjectKey(request) {
381
+ const record = { ...request };
382
+ delete record.projectKey;
383
+ delete record.ProjectKey;
384
+ return record;
385
+ }