@wix/auto_sdk_papyrus_documents 1.0.1 → 1.0.2

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.
@@ -1,1118 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- ContentDisposition: () => ContentDisposition,
24
- Format: () => Format,
25
- PageOverflow: () => PageOverflow,
26
- PaperSize: () => PaperSize,
27
- RenderFormat: () => RenderFormat,
28
- RenderStatus: () => RenderStatus,
29
- RequestedFields: () => RequestedFields,
30
- ResizeOption: () => ResizeOption,
31
- SortOrder: () => SortOrder,
32
- WebhookIdentityType: () => WebhookIdentityType,
33
- WixMpClientVersion: () => WixMpClientVersion,
34
- createDocument: () => createDocument4,
35
- deleteDocument: () => deleteDocument4,
36
- downloadDocument: () => downloadDocument4,
37
- downloadDocumentSource: () => downloadDocumentSource4,
38
- getDocument: () => getDocument4,
39
- getDownloadPage: () => getDownloadPage4,
40
- getDownloadUrl: () => getDownloadUrl4,
41
- onDocumentCreated: () => onDocumentCreated2,
42
- onDocumentDeleted: () => onDocumentDeleted2,
43
- onDocumentRenderDelayed: () => onDocumentRenderDelayed2,
44
- onDocumentRenderFailed: () => onDocumentRenderFailed2,
45
- onDocumentRendered: () => onDocumentRendered2,
46
- onDocumentUpdated: () => onDocumentUpdated2,
47
- queryDocument: () => queryDocument4,
48
- redirectToDocument: () => redirectToDocument4,
49
- updateDocument: () => updateDocument4,
50
- utils: () => utils
51
- });
52
- module.exports = __toCommonJS(index_exports);
53
-
54
- // src/papyrus-v1-document-documents.public.ts
55
- var import_rename_all_nested_keys2 = require("@wix/sdk-runtime/rename-all-nested-keys");
56
- var import_timestamp3 = require("@wix/sdk-runtime/transformations/timestamp");
57
- var import_transform_paths3 = require("@wix/sdk-runtime/transformations/transform-paths");
58
- var import_sdk_types = require("@wix/sdk-types");
59
-
60
- // src/papyrus-v1-document-documents.universal.ts
61
- var import_transform_error = require("@wix/sdk-runtime/transform-error");
62
- var import_query_builder = require("@wix/sdk-runtime/query-builder");
63
- var import_rename_all_nested_keys = require("@wix/sdk-runtime/rename-all-nested-keys");
64
-
65
- // src/papyrus-v1-document-documents.http.ts
66
- var import_rest_modules = require("@wix/sdk-runtime/rest-modules");
67
- var import_float = require("@wix/sdk-runtime/transformations/float");
68
- var import_bytes = require("@wix/sdk-runtime/transformations/bytes");
69
- var import_timestamp = require("@wix/sdk-runtime/transformations/timestamp");
70
- var import_timestamp2 = require("@wix/sdk-runtime/transformations/timestamp");
71
- var import_transform_paths = require("@wix/sdk-runtime/transformations/transform-paths");
72
- var import_rest_modules2 = require("@wix/sdk-runtime/rest-modules");
73
- function resolveWixPapyrusV1DownloadPageControllerUrl(opts) {
74
- const domainToMappings = {
75
- "api._base_domain_": [
76
- {
77
- srcPath: "/papyrus-document",
78
- destPath: ""
79
- }
80
- ],
81
- "www.wixapis.com": [
82
- {
83
- srcPath: "/papyrus-document/v1/documents",
84
- destPath: "/v1/documents"
85
- }
86
- ],
87
- "papyrus.wixapps.net": [
88
- {
89
- srcPath: "/download",
90
- destPath: "/download"
91
- },
92
- {
93
- srcPath: "/papyrus-document",
94
- destPath: ""
95
- },
96
- {
97
- srcPath: "/view",
98
- destPath: "/view"
99
- }
100
- ],
101
- "manage._base_domain_": [
102
- {
103
- srcPath: "/papyrus-document",
104
- destPath: ""
105
- }
106
- ],
107
- "api._api_base_domain_": [
108
- {
109
- srcPath: "/papyrus-document",
110
- destPath: ""
111
- }
112
- ]
113
- };
114
- return (0, import_rest_modules2.resolveUrl)(Object.assign(opts, { domainToMappings }));
115
- }
116
- function resolveWixPapyrusV1DocumentServiceUrl(opts) {
117
- const domainToMappings = {
118
- "api._base_domain_": [
119
- {
120
- srcPath: "/papyrus-document",
121
- destPath: ""
122
- }
123
- ],
124
- "www.wixapis.com": [
125
- {
126
- srcPath: "/papyrus-document/v1/documents",
127
- destPath: "/v1/documents"
128
- }
129
- ],
130
- "papyrus.wixapps.net": [
131
- {
132
- srcPath: "/download",
133
- destPath: "/download"
134
- },
135
- {
136
- srcPath: "/papyrus-document",
137
- destPath: ""
138
- },
139
- {
140
- srcPath: "/view",
141
- destPath: "/view"
142
- }
143
- ],
144
- "manage._base_domain_": [
145
- {
146
- srcPath: "/papyrus-document",
147
- destPath: ""
148
- }
149
- ],
150
- "api._api_base_domain_": [
151
- {
152
- srcPath: "/papyrus-document",
153
- destPath: ""
154
- }
155
- ]
156
- };
157
- return (0, import_rest_modules2.resolveUrl)(Object.assign(opts, { domainToMappings }));
158
- }
159
- var PACKAGE_NAME = "@wix/auto_sdk_papyrus_documents";
160
- function createDocument(payload) {
161
- function __createDocument({ host }) {
162
- const serializedData = (0, import_transform_paths.transformPaths)(payload, [
163
- {
164
- transformFn: import_timestamp.transformSDKTimestampToRESTTimestamp,
165
- paths: [
166
- { path: "document.createdDate" },
167
- { path: "document.updatedDate" },
168
- { path: "document.expirationDate" }
169
- ]
170
- }
171
- ]);
172
- const metadata = {
173
- entityFqdn: "wix.papyrus.v1.document",
174
- method: "POST",
175
- methodFqn: "wix.papyrus.v1.DocumentService.CreateDocument",
176
- packageName: PACKAGE_NAME,
177
- migrationOptions: {
178
- optInTransformResponse: true
179
- },
180
- url: resolveWixPapyrusV1DocumentServiceUrl({
181
- protoPath: "/v1/documents",
182
- data: serializedData,
183
- host
184
- }),
185
- data: serializedData,
186
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
187
- {
188
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
189
- paths: [
190
- { path: "document.createdDate" },
191
- { path: "document.updatedDate" },
192
- { path: "document.expirationDate" }
193
- ]
194
- }
195
- ])
196
- };
197
- return metadata;
198
- }
199
- return __createDocument;
200
- }
201
- function getDocument(payload) {
202
- function __getDocument({ host }) {
203
- const metadata = {
204
- entityFqdn: "wix.papyrus.v1.document",
205
- method: "GET",
206
- methodFqn: "wix.papyrus.v1.DocumentService.GetDocument",
207
- packageName: PACKAGE_NAME,
208
- migrationOptions: {
209
- optInTransformResponse: true
210
- },
211
- url: resolveWixPapyrusV1DocumentServiceUrl({
212
- protoPath: "/v1/documents/{documentId}",
213
- data: payload,
214
- host
215
- }),
216
- params: (0, import_rest_modules.toURLSearchParams)(payload),
217
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
218
- {
219
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
220
- paths: [
221
- { path: "document.createdDate" },
222
- { path: "document.updatedDate" },
223
- { path: "document.expirationDate" }
224
- ]
225
- }
226
- ])
227
- };
228
- return metadata;
229
- }
230
- return __getDocument;
231
- }
232
- function deleteDocument(payload) {
233
- function __deleteDocument({ host }) {
234
- const metadata = {
235
- entityFqdn: "wix.papyrus.v1.document",
236
- method: "DELETE",
237
- methodFqn: "wix.papyrus.v1.DocumentService.DeleteDocument",
238
- packageName: PACKAGE_NAME,
239
- migrationOptions: {
240
- optInTransformResponse: true
241
- },
242
- url: resolveWixPapyrusV1DocumentServiceUrl({
243
- protoPath: "/v1/documents/{documentId}",
244
- data: payload,
245
- host
246
- }),
247
- params: (0, import_rest_modules.toURLSearchParams)(payload),
248
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
249
- {
250
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
251
- paths: [
252
- { path: "document.createdDate" },
253
- { path: "document.updatedDate" },
254
- { path: "document.expirationDate" }
255
- ]
256
- }
257
- ])
258
- };
259
- return metadata;
260
- }
261
- return __deleteDocument;
262
- }
263
- function queryDocument(payload) {
264
- function __queryDocument({ host }) {
265
- const serializedData = (0, import_transform_paths.transformPaths)(payload, [
266
- {
267
- transformFn: import_float.transformSDKFloatToRESTFloat,
268
- paths: [
269
- { path: "query.sort.origin.latitude" },
270
- { path: "query.sort.origin.longitude" }
271
- ]
272
- }
273
- ]);
274
- const metadata = {
275
- entityFqdn: "wix.papyrus.v1.document",
276
- method: "POST",
277
- methodFqn: "wix.papyrus.v1.DocumentService.QueryDocument",
278
- packageName: PACKAGE_NAME,
279
- migrationOptions: {
280
- optInTransformResponse: true
281
- },
282
- url: resolveWixPapyrusV1DocumentServiceUrl({
283
- protoPath: "/v1/documents/query",
284
- data: serializedData,
285
- host
286
- }),
287
- data: serializedData,
288
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
289
- {
290
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
291
- paths: [
292
- { path: "documents.createdDate" },
293
- { path: "documents.updatedDate" },
294
- { path: "documents.expirationDate" }
295
- ]
296
- }
297
- ])
298
- };
299
- return metadata;
300
- }
301
- return __queryDocument;
302
- }
303
- function updateDocument(payload) {
304
- function __updateDocument({ host }) {
305
- const metadata = {
306
- entityFqdn: "wix.papyrus.v1.document",
307
- method: "PATCH",
308
- methodFqn: "wix.papyrus.v1.DocumentService.UpdateDocument",
309
- packageName: PACKAGE_NAME,
310
- migrationOptions: {
311
- optInTransformResponse: true
312
- },
313
- url: resolveWixPapyrusV1DocumentServiceUrl({
314
- protoPath: "/v1/documents/{id}",
315
- data: payload,
316
- host
317
- }),
318
- data: payload,
319
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
320
- {
321
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
322
- paths: [
323
- { path: "document.createdDate" },
324
- { path: "document.updatedDate" },
325
- { path: "document.expirationDate" }
326
- ]
327
- }
328
- ])
329
- };
330
- return metadata;
331
- }
332
- return __updateDocument;
333
- }
334
- function downloadDocument(payload) {
335
- function __downloadDocument({ host }) {
336
- const metadata = {
337
- entityFqdn: "wix.papyrus.v1.document",
338
- method: "GET",
339
- methodFqn: "wix.papyrus.v1.DocumentService.DownloadDocument",
340
- packageName: PACKAGE_NAME,
341
- migrationOptions: {
342
- optInTransformResponse: true
343
- },
344
- url: resolveWixPapyrusV1DocumentServiceUrl({
345
- protoPath: "/v1/documents/download/{documentId}",
346
- data: payload,
347
- host
348
- }),
349
- params: (0, import_rest_modules.toURLSearchParams)(payload),
350
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
351
- {
352
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
353
- paths: [{ path: "expirationDate" }]
354
- }
355
- ])
356
- };
357
- return metadata;
358
- }
359
- return __downloadDocument;
360
- }
361
- function getDownloadUrl(payload) {
362
- function __getDownloadUrl({ host }) {
363
- const metadata = {
364
- entityFqdn: "wix.papyrus.v1.document",
365
- method: "GET",
366
- methodFqn: "wix.papyrus.v1.DocumentService.GetDownloadUrl",
367
- packageName: PACKAGE_NAME,
368
- migrationOptions: {
369
- optInTransformResponse: true
370
- },
371
- url: resolveWixPapyrusV1DocumentServiceUrl({
372
- protoPath: "/v1/documents/download-url",
373
- data: payload,
374
- host
375
- }),
376
- params: (0, import_rest_modules.toURLSearchParams)(payload),
377
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
378
- {
379
- transformFn: import_timestamp2.transformRESTTimestampToSDKTimestamp,
380
- paths: [{ path: "expirationDate" }]
381
- }
382
- ])
383
- };
384
- return metadata;
385
- }
386
- return __getDownloadUrl;
387
- }
388
- function downloadDocumentSource(payload) {
389
- function __downloadDocumentSource({ host }) {
390
- const metadata = {
391
- entityFqdn: "wix.papyrus.v1.document",
392
- method: "GET",
393
- methodFqn: "wix.papyrus.v1.DocumentService.DownloadDocumentSource",
394
- packageName: PACKAGE_NAME,
395
- migrationOptions: {
396
- optInTransformResponse: true
397
- },
398
- url: resolveWixPapyrusV1DocumentServiceUrl({
399
- protoPath: "/v1/documents/download/{documentId}/source",
400
- data: payload,
401
- host
402
- }),
403
- params: (0, import_rest_modules.toURLSearchParams)(payload)
404
- };
405
- return metadata;
406
- }
407
- return __downloadDocumentSource;
408
- }
409
- function getDownloadPage(payload) {
410
- function __getDownloadPage({ host }) {
411
- const metadata = {
412
- entityFqdn: "wix.papyrus.v1.document",
413
- method: "GET",
414
- methodFqn: "wix.papyrus.v1.DownloadPageController.GetDownloadPage",
415
- packageName: PACKAGE_NAME,
416
- migrationOptions: {
417
- optInTransformResponse: true
418
- },
419
- url: resolveWixPapyrusV1DownloadPageControllerUrl({
420
- protoPath: "/download",
421
- data: payload,
422
- host
423
- }),
424
- params: (0, import_rest_modules.toURLSearchParams)(payload),
425
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
426
- {
427
- transformFn: import_bytes.transformRESTBytesToSDKBytes,
428
- paths: [{ path: "body" }]
429
- }
430
- ])
431
- };
432
- return metadata;
433
- }
434
- return __getDownloadPage;
435
- }
436
- function redirectToDocument(payload) {
437
- function __redirectToDocument({ host }) {
438
- const metadata = {
439
- entityFqdn: "wix.papyrus.v1.document",
440
- method: "GET",
441
- methodFqn: "wix.papyrus.v1.DownloadPageController.RedirectToDocument",
442
- packageName: PACKAGE_NAME,
443
- migrationOptions: {
444
- optInTransformResponse: true
445
- },
446
- url: resolveWixPapyrusV1DownloadPageControllerUrl({
447
- protoPath: "/view",
448
- data: payload,
449
- host
450
- }),
451
- params: (0, import_rest_modules.toURLSearchParams)(payload),
452
- transformResponse: (payload2) => (0, import_transform_paths.transformPaths)(payload2, [
453
- {
454
- transformFn: import_bytes.transformRESTBytesToSDKBytes,
455
- paths: [{ path: "body" }]
456
- }
457
- ])
458
- };
459
- return metadata;
460
- }
461
- return __redirectToDocument;
462
- }
463
-
464
- // src/papyrus-v1-document-documents.universal.ts
465
- var import_transform_paths2 = require("@wix/sdk-runtime/transformations/transform-paths");
466
- var import_query_builder_utils = require("@wix/sdk-runtime/query-builder-utils");
467
- var RenderStatus = /* @__PURE__ */ ((RenderStatus2) => {
468
- RenderStatus2["UNKNOWN"] = "UNKNOWN";
469
- RenderStatus2["ACCEPTED"] = "ACCEPTED";
470
- RenderStatus2["RENDERING"] = "RENDERING";
471
- RenderStatus2["READY"] = "READY";
472
- RenderStatus2["FAILED"] = "FAILED";
473
- RenderStatus2["EXPIRED"] = "EXPIRED";
474
- return RenderStatus2;
475
- })(RenderStatus || {});
476
- var Format = /* @__PURE__ */ ((Format2) => {
477
- Format2["UNKNOWN"] = "UNKNOWN";
478
- Format2["PDF"] = "PDF";
479
- return Format2;
480
- })(Format || {});
481
- var WixMpClientVersion = /* @__PURE__ */ ((WixMpClientVersion2) => {
482
- WixMpClientVersion2["UNKNOWN"] = "UNKNOWN";
483
- WixMpClientVersion2["MP_V1"] = "MP_V1";
484
- WixMpClientVersion2["MP_V2"] = "MP_V2";
485
- return WixMpClientVersion2;
486
- })(WixMpClientVersion || {});
487
- var RequestedFields = /* @__PURE__ */ ((RequestedFields2) => {
488
- RequestedFields2["DOCUMENT_CONTENT"] = "DOCUMENT_CONTENT";
489
- return RequestedFields2;
490
- })(RequestedFields || {});
491
- var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
492
- SortOrder2["ASC"] = "ASC";
493
- SortOrder2["DESC"] = "DESC";
494
- return SortOrder2;
495
- })(SortOrder || {});
496
- var ContentDisposition = /* @__PURE__ */ ((ContentDisposition2) => {
497
- ContentDisposition2["UNKNOWN_CONTENT_DISPOSITION"] = "UNKNOWN_CONTENT_DISPOSITION";
498
- ContentDisposition2["ATTACHMENT"] = "ATTACHMENT";
499
- ContentDisposition2["INLINE"] = "INLINE";
500
- return ContentDisposition2;
501
- })(ContentDisposition || {});
502
- var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
503
- WebhookIdentityType2["UNKNOWN"] = "UNKNOWN";
504
- WebhookIdentityType2["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
505
- WebhookIdentityType2["MEMBER"] = "MEMBER";
506
- WebhookIdentityType2["WIX_USER"] = "WIX_USER";
507
- WebhookIdentityType2["APP"] = "APP";
508
- return WebhookIdentityType2;
509
- })(WebhookIdentityType || {});
510
- var ResizeOption = /* @__PURE__ */ ((ResizeOption2) => {
511
- ResizeOption2["FIT"] = "FIT";
512
- ResizeOption2["CROP"] = "CROP";
513
- return ResizeOption2;
514
- })(ResizeOption || {});
515
- var PaperSize = /* @__PURE__ */ ((PaperSize2) => {
516
- PaperSize2["A4_PORTRAIT"] = "A4_PORTRAIT";
517
- PaperSize2["A4_LANDSCAPE"] = "A4_LANDSCAPE";
518
- return PaperSize2;
519
- })(PaperSize || {});
520
- var PageOverflow = /* @__PURE__ */ ((PageOverflow2) => {
521
- PageOverflow2["CONTENT_HIDDEN"] = "CONTENT_HIDDEN";
522
- PageOverflow2["CONTENT_BREAK"] = "CONTENT_BREAK";
523
- return PageOverflow2;
524
- })(PageOverflow || {});
525
- var RenderFormat = /* @__PURE__ */ ((RenderFormat2) => {
526
- RenderFormat2["PDF"] = "PDF";
527
- RenderFormat2["HTML"] = "HTML";
528
- return RenderFormat2;
529
- })(RenderFormat || {});
530
- async function createDocument2(options) {
531
- const { httpClient, sideEffects } = arguments[1];
532
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
533
- document: options?.document
534
- });
535
- const reqOpts = createDocument(payload);
536
- sideEffects?.onSiteCall?.();
537
- try {
538
- const result = await httpClient.request(reqOpts);
539
- sideEffects?.onSuccess?.(result);
540
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data)?.document;
541
- } catch (err) {
542
- const transformedError = (0, import_transform_error.transformError)(
543
- err,
544
- {
545
- spreadPathsToArguments: {},
546
- explicitPathsToArguments: { document: "$[0].document" },
547
- singleArgumentUnchanged: false
548
- },
549
- ["options"]
550
- );
551
- sideEffects?.onError?.(err);
552
- throw transformedError;
553
- }
554
- }
555
- async function getDocument2(documentId, options) {
556
- const { httpClient, sideEffects } = arguments[2];
557
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
558
- documentId,
559
- fields: options?.fields
560
- });
561
- const reqOpts = getDocument(payload);
562
- sideEffects?.onSiteCall?.();
563
- try {
564
- const result = await httpClient.request(reqOpts);
565
- sideEffects?.onSuccess?.(result);
566
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data)?.document;
567
- } catch (err) {
568
- const transformedError = (0, import_transform_error.transformError)(
569
- err,
570
- {
571
- spreadPathsToArguments: {},
572
- explicitPathsToArguments: { documentId: "$[0]", fields: "$[1].fields" },
573
- singleArgumentUnchanged: false
574
- },
575
- ["documentId", "options"]
576
- );
577
- sideEffects?.onError?.(err);
578
- throw transformedError;
579
- }
580
- }
581
- async function deleteDocument2(documentId) {
582
- const { httpClient, sideEffects } = arguments[1];
583
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
584
- documentId
585
- });
586
- const reqOpts = deleteDocument(payload);
587
- sideEffects?.onSiteCall?.();
588
- try {
589
- const result = await httpClient.request(reqOpts);
590
- sideEffects?.onSuccess?.(result);
591
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
592
- } catch (err) {
593
- const transformedError = (0, import_transform_error.transformError)(
594
- err,
595
- {
596
- spreadPathsToArguments: {},
597
- explicitPathsToArguments: { documentId: "$[0]" },
598
- singleArgumentUnchanged: false
599
- },
600
- ["documentId"]
601
- );
602
- sideEffects?.onError?.(err);
603
- throw transformedError;
604
- }
605
- }
606
- function queryDocument2(options) {
607
- const { httpClient, sideEffects } = arguments[1];
608
- return (0, import_query_builder.queryBuilder)({
609
- func: async (payload) => {
610
- const reqOpts = queryDocument({
611
- ...payload,
612
- ...options ?? {}
613
- });
614
- sideEffects?.onSiteCall?.();
615
- try {
616
- const result = await httpClient.request(reqOpts);
617
- sideEffects?.onSuccess?.(result);
618
- return result;
619
- } catch (err) {
620
- sideEffects?.onError?.(err);
621
- throw err;
622
- }
623
- },
624
- requestTransformer: (query) => {
625
- const args = [query, options];
626
- return (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
627
- ...args?.[1],
628
- query: args?.[0]
629
- });
630
- },
631
- responseTransformer: ({ data }) => {
632
- const transformedData = (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(
633
- (0, import_transform_paths2.transformPaths)(data, [])
634
- );
635
- return {
636
- items: transformedData?.documents,
637
- pagingMetadata: transformedData?.metadata
638
- };
639
- },
640
- errorTransformer: (err) => {
641
- const transformedError = (0, import_transform_error.transformError)(err, {
642
- spreadPathsToArguments: {},
643
- explicitPathsToArguments: { query: "$[0]" },
644
- singleArgumentUnchanged: false
645
- });
646
- throw transformedError;
647
- },
648
- pagingMethod: "CURSOR",
649
- transformationPaths: {}
650
- });
651
- }
652
- async function typedQueryDocument(query, options) {
653
- const { httpClient, sideEffects } = arguments[2];
654
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
655
- query,
656
- ...options
657
- });
658
- const reqOpts = queryDocument(payload);
659
- sideEffects?.onSiteCall?.();
660
- try {
661
- const result = await httpClient.request(reqOpts);
662
- sideEffects?.onSuccess?.(result);
663
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
664
- } catch (err) {
665
- const transformedError = (0, import_transform_error.transformError)(
666
- err,
667
- {
668
- spreadPathsToArguments: {},
669
- explicitPathsToArguments: { query: "$[0]" },
670
- singleArgumentUnchanged: false
671
- },
672
- ["query", "options"]
673
- );
674
- sideEffects?.onError?.(err);
675
- throw transformedError;
676
- }
677
- }
678
- var utils = {
679
- query: /* @__PURE__ */ (0, import_query_builder_utils.createQueryUtils)()
680
- };
681
- async function updateDocument2(_id, options) {
682
- const { httpClient, sideEffects } = arguments[2];
683
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
684
- id: _id,
685
- renderStatus: options?.renderStatus,
686
- file: options?.file,
687
- sourceFile: options?.sourceFile
688
- });
689
- const reqOpts = updateDocument(payload);
690
- sideEffects?.onSiteCall?.();
691
- try {
692
- const result = await httpClient.request(reqOpts);
693
- sideEffects?.onSuccess?.(result);
694
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
695
- } catch (err) {
696
- const transformedError = (0, import_transform_error.transformError)(
697
- err,
698
- {
699
- spreadPathsToArguments: {},
700
- explicitPathsToArguments: {
701
- id: "$[0]",
702
- renderStatus: "$[1].renderStatus",
703
- file: "$[1].file",
704
- sourceFile: "$[1].sourceFile"
705
- },
706
- singleArgumentUnchanged: false
707
- },
708
- ["_id", "options"]
709
- );
710
- sideEffects?.onError?.(err);
711
- throw transformedError;
712
- }
713
- }
714
- async function downloadDocument2(documentId, options) {
715
- const { httpClient, sideEffects } = arguments[2];
716
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
717
- documentId,
718
- urlExpirationInSeconds: options?.urlExpirationInSeconds,
719
- contentDisposition: options?.contentDisposition
720
- });
721
- const reqOpts = downloadDocument(payload);
722
- sideEffects?.onSiteCall?.();
723
- try {
724
- const result = await httpClient.request(reqOpts);
725
- sideEffects?.onSuccess?.(result);
726
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
727
- } catch (err) {
728
- const transformedError = (0, import_transform_error.transformError)(
729
- err,
730
- {
731
- spreadPathsToArguments: {},
732
- explicitPathsToArguments: {
733
- documentId: "$[0]",
734
- urlExpirationInSeconds: "$[1].urlExpirationInSeconds",
735
- contentDisposition: "$[1].contentDisposition"
736
- },
737
- singleArgumentUnchanged: false
738
- },
739
- ["documentId", "options"]
740
- );
741
- sideEffects?.onError?.(err);
742
- throw transformedError;
743
- }
744
- }
745
- async function getDownloadUrl2(options) {
746
- const { httpClient, sideEffects } = arguments[1];
747
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
748
- documentId: options?.documentId,
749
- externalId: options?.externalId,
750
- fileToken: options?.fileToken,
751
- urlExpirationInSeconds: options?.urlExpirationInSeconds,
752
- downloadButtonText: options?.downloadButtonText,
753
- contentDisposition: options?.contentDisposition
754
- });
755
- const reqOpts = getDownloadUrl(payload);
756
- sideEffects?.onSiteCall?.();
757
- try {
758
- const result = await httpClient.request(reqOpts);
759
- sideEffects?.onSuccess?.(result);
760
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
761
- } catch (err) {
762
- const transformedError = (0, import_transform_error.transformError)(
763
- err,
764
- {
765
- spreadPathsToArguments: {},
766
- explicitPathsToArguments: {
767
- documentId: "$[0].documentId",
768
- externalId: "$[0].externalId",
769
- fileToken: "$[0].fileToken",
770
- urlExpirationInSeconds: "$[0].urlExpirationInSeconds",
771
- downloadButtonText: "$[0].downloadButtonText",
772
- contentDisposition: "$[0].contentDisposition"
773
- },
774
- singleArgumentUnchanged: false
775
- },
776
- ["options"]
777
- );
778
- sideEffects?.onError?.(err);
779
- throw transformedError;
780
- }
781
- }
782
- async function downloadDocumentSource2(documentId, options) {
783
- const { httpClient, sideEffects } = arguments[2];
784
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({
785
- documentId,
786
- contentDisposition: options?.contentDisposition
787
- });
788
- const reqOpts = downloadDocumentSource(payload);
789
- sideEffects?.onSiteCall?.();
790
- try {
791
- const result = await httpClient.request(reqOpts);
792
- sideEffects?.onSuccess?.(result);
793
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
794
- } catch (err) {
795
- const transformedError = (0, import_transform_error.transformError)(
796
- err,
797
- {
798
- spreadPathsToArguments: {},
799
- explicitPathsToArguments: {
800
- documentId: "$[0]",
801
- contentDisposition: "$[1].contentDisposition"
802
- },
803
- singleArgumentUnchanged: false
804
- },
805
- ["documentId", "options"]
806
- );
807
- sideEffects?.onError?.(err);
808
- throw transformedError;
809
- }
810
- }
811
- async function getDownloadPage2(file) {
812
- const { httpClient, sideEffects } = arguments[1];
813
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({ file });
814
- const reqOpts = getDownloadPage(payload);
815
- sideEffects?.onSiteCall?.();
816
- try {
817
- const result = await httpClient.request(reqOpts);
818
- sideEffects?.onSuccess?.(result);
819
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
820
- } catch (err) {
821
- const transformedError = (0, import_transform_error.transformError)(
822
- err,
823
- {
824
- spreadPathsToArguments: {},
825
- explicitPathsToArguments: { file: "$[0]" },
826
- singleArgumentUnchanged: false
827
- },
828
- ["file"]
829
- );
830
- sideEffects?.onError?.(err);
831
- throw transformedError;
832
- }
833
- }
834
- async function redirectToDocument2(file) {
835
- const { httpClient, sideEffects } = arguments[1];
836
- const payload = (0, import_rename_all_nested_keys.renameKeysFromSDKRequestToRESTRequest)({ file });
837
- const reqOpts = redirectToDocument(payload);
838
- sideEffects?.onSiteCall?.();
839
- try {
840
- const result = await httpClient.request(reqOpts);
841
- sideEffects?.onSuccess?.(result);
842
- return (0, import_rename_all_nested_keys.renameKeysFromRESTResponseToSDKResponse)(result.data);
843
- } catch (err) {
844
- const transformedError = (0, import_transform_error.transformError)(
845
- err,
846
- {
847
- spreadPathsToArguments: {},
848
- explicitPathsToArguments: { file: "$[0]" },
849
- singleArgumentUnchanged: false
850
- },
851
- ["file"]
852
- );
853
- sideEffects?.onError?.(err);
854
- throw transformedError;
855
- }
856
- }
857
-
858
- // src/papyrus-v1-document-documents.public.ts
859
- function createDocument3(httpClient) {
860
- return (options) => createDocument2(
861
- options,
862
- // @ts-ignore
863
- { httpClient }
864
- );
865
- }
866
- function getDocument3(httpClient) {
867
- return (documentId, options) => getDocument2(
868
- documentId,
869
- options,
870
- // @ts-ignore
871
- { httpClient }
872
- );
873
- }
874
- function deleteDocument3(httpClient) {
875
- return (documentId) => deleteDocument2(
876
- documentId,
877
- // @ts-ignore
878
- { httpClient }
879
- );
880
- }
881
- function queryDocument3(httpClient) {
882
- return (options) => queryDocument2(
883
- options,
884
- // @ts-ignore
885
- { httpClient }
886
- );
887
- }
888
- function typedQueryDocument2(httpClient) {
889
- return (query, options) => typedQueryDocument(
890
- query,
891
- options,
892
- // @ts-ignore
893
- { httpClient }
894
- );
895
- }
896
- function updateDocument3(httpClient) {
897
- return (_id, options) => updateDocument2(
898
- _id,
899
- options,
900
- // @ts-ignore
901
- { httpClient }
902
- );
903
- }
904
- function downloadDocument3(httpClient) {
905
- return (documentId, options) => downloadDocument2(
906
- documentId,
907
- options,
908
- // @ts-ignore
909
- { httpClient }
910
- );
911
- }
912
- function getDownloadUrl3(httpClient) {
913
- return (options) => getDownloadUrl2(
914
- options,
915
- // @ts-ignore
916
- { httpClient }
917
- );
918
- }
919
- function downloadDocumentSource3(httpClient) {
920
- return (documentId, options) => downloadDocumentSource2(
921
- documentId,
922
- options,
923
- // @ts-ignore
924
- { httpClient }
925
- );
926
- }
927
- function getDownloadPage3(httpClient) {
928
- return (file) => getDownloadPage2(
929
- file,
930
- // @ts-ignore
931
- { httpClient }
932
- );
933
- }
934
- function redirectToDocument3(httpClient) {
935
- return (file) => redirectToDocument2(
936
- file,
937
- // @ts-ignore
938
- { httpClient }
939
- );
940
- }
941
- var onDocumentCreated = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
942
- "wix.papyrus.v1.document_created",
943
- true,
944
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
945
- (0, import_transform_paths3.transformPaths)(event, [
946
- {
947
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
948
- paths: [
949
- { path: "entity.createdDate" },
950
- { path: "entity.updatedDate" },
951
- { path: "entity.expirationDate" },
952
- { path: "metadata.eventTime" }
953
- ]
954
- }
955
- ])
956
- )
957
- )();
958
- var onDocumentDeleted = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
959
- "wix.papyrus.v1.document_deleted",
960
- true,
961
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
962
- (0, import_transform_paths3.transformPaths)(event, [
963
- {
964
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
965
- paths: [
966
- { path: "undefined.createdDate" },
967
- { path: "undefined.updatedDate" },
968
- { path: "undefined.expirationDate" },
969
- { path: "metadata.eventTime" }
970
- ]
971
- }
972
- ])
973
- )
974
- )();
975
- var onDocumentRenderDelayed = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
976
- "wix.papyrus.v1.document_document_render_delayed",
977
- true,
978
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
979
- (0, import_transform_paths3.transformPaths)(event, [
980
- {
981
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
982
- paths: [
983
- { path: "data.document.createdDate" },
984
- { path: "data.document.updatedDate" },
985
- { path: "data.document.expirationDate" },
986
- { path: "metadata.eventTime" }
987
- ]
988
- }
989
- ])
990
- )
991
- )();
992
- var onDocumentRenderFailed = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
993
- "wix.papyrus.v1.document_document_render_failed",
994
- true,
995
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
996
- (0, import_transform_paths3.transformPaths)(event, [
997
- {
998
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
999
- paths: [
1000
- { path: "data.document.createdDate" },
1001
- { path: "data.document.updatedDate" },
1002
- { path: "data.document.expirationDate" },
1003
- { path: "metadata.eventTime" }
1004
- ]
1005
- }
1006
- ])
1007
- )
1008
- )();
1009
- var onDocumentRendered = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
1010
- "wix.papyrus.v1.document_document_rendered",
1011
- true,
1012
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
1013
- (0, import_transform_paths3.transformPaths)(event, [
1014
- {
1015
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
1016
- paths: [
1017
- { path: "data.document.createdDate" },
1018
- { path: "data.document.updatedDate" },
1019
- { path: "data.document.expirationDate" },
1020
- { path: "metadata.eventTime" }
1021
- ]
1022
- }
1023
- ])
1024
- )
1025
- )();
1026
- var onDocumentUpdated = /* @__PURE__ */ (0, import_sdk_types.EventDefinition)(
1027
- "wix.papyrus.v1.document_updated",
1028
- true,
1029
- (event) => (0, import_rename_all_nested_keys2.renameKeysFromRESTResponseToSDKResponse)(
1030
- (0, import_transform_paths3.transformPaths)(event, [
1031
- {
1032
- transformFn: import_timestamp3.transformRESTTimestampToSDKTimestamp,
1033
- paths: [
1034
- { path: "entity.createdDate" },
1035
- { path: "entity.updatedDate" },
1036
- { path: "entity.expirationDate" },
1037
- { path: "metadata.eventTime" }
1038
- ]
1039
- }
1040
- ])
1041
- )
1042
- )();
1043
-
1044
- // src/papyrus-v1-document-documents.context.ts
1045
- var import_rest_modules3 = require("@wix/sdk-runtime/rest-modules");
1046
- var import_event_definition_modules = require("@wix/sdk-runtime/event-definition-modules");
1047
- var import_query_method_router = require("@wix/sdk-runtime/query-method-router");
1048
- function customQueryDocument(httpClient) {
1049
- const router = /* @__PURE__ */ (0, import_query_method_router.createQueryOverloadRouter)({
1050
- builderQueryFunction: (options) => queryDocument3(httpClient)(options),
1051
- typedQueryFunction: (query, options) => typedQueryDocument2(httpClient)(query, options),
1052
- hasOptionsParameter: true
1053
- });
1054
- function overloadedQuery(queryOrOptions, options) {
1055
- return router(...arguments);
1056
- }
1057
- return overloadedQuery;
1058
- }
1059
- var createDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(createDocument3);
1060
- var getDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(getDocument3);
1061
- var deleteDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(deleteDocument3);
1062
- var updateDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(updateDocument3);
1063
- var downloadDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(downloadDocument3);
1064
- var getDownloadUrl4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(getDownloadUrl3);
1065
- var downloadDocumentSource4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(downloadDocumentSource3);
1066
- var getDownloadPage4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(getDownloadPage3);
1067
- var redirectToDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(redirectToDocument3);
1068
- var queryDocument4 = /* @__PURE__ */ (0, import_rest_modules3.createRESTModule)(customQueryDocument);
1069
- var onDocumentCreated2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1070
- onDocumentCreated
1071
- );
1072
- var onDocumentDeleted2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1073
- onDocumentDeleted
1074
- );
1075
- var onDocumentRenderDelayed2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1076
- onDocumentRenderDelayed
1077
- );
1078
- var onDocumentRenderFailed2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1079
- onDocumentRenderFailed
1080
- );
1081
- var onDocumentRendered2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1082
- onDocumentRendered
1083
- );
1084
- var onDocumentUpdated2 = /* @__PURE__ */ (0, import_event_definition_modules.createEventModule)(
1085
- onDocumentUpdated
1086
- );
1087
- // Annotate the CommonJS export names for ESM import in node:
1088
- 0 && (module.exports = {
1089
- ContentDisposition,
1090
- Format,
1091
- PageOverflow,
1092
- PaperSize,
1093
- RenderFormat,
1094
- RenderStatus,
1095
- RequestedFields,
1096
- ResizeOption,
1097
- SortOrder,
1098
- WebhookIdentityType,
1099
- WixMpClientVersion,
1100
- createDocument,
1101
- deleteDocument,
1102
- downloadDocument,
1103
- downloadDocumentSource,
1104
- getDocument,
1105
- getDownloadPage,
1106
- getDownloadUrl,
1107
- onDocumentCreated,
1108
- onDocumentDeleted,
1109
- onDocumentRenderDelayed,
1110
- onDocumentRenderFailed,
1111
- onDocumentRendered,
1112
- onDocumentUpdated,
1113
- queryDocument,
1114
- redirectToDocument,
1115
- updateDocument,
1116
- utils
1117
- });
1118
- //# sourceMappingURL=index.js.map