calmlens 0.20.0 → 0.22.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.
- package/README.md +15 -10
- package/bin/calmlens.js +1848 -679
- package/cjs/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-BWjZ9ntu.d.ts} +2 -2
- package/cjs/{BrowserUpload-CjSHjx3C.js → BrowserUpload-Bwlib4Zc.js} +1 -1
- package/cjs/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
- package/cjs/{CalmLensAppClient-NaCxOVlM.js → CalmLensAppClient-DUYMo9PZ.js} +30 -10
- package/cjs/{CalmLensOptionKeys-p2QK687A.js → CalmLensOptionKeys-YvgV995V.js} +318 -374
- package/cjs/{CalmLensServerClient-BDzTthxE.js → CalmLensServerClient-3N-gdsxC.js} +346 -89
- package/cjs/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
- package/cjs/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
- package/cjs/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/cjs/Core-C33pkBmf.d.ts +826 -0
- package/cjs/Core-Cm5Z1oJ9.js +1001 -0
- package/cjs/FileIcons-4qSX7DW2.d.ts +67 -0
- package/cjs/{ModerationContextLimits-2nIv7Zh3.js → ModerationContextLimits-ud1xpZRK.js} +727 -268
- package/cjs/{ReactUpload-BdTRCTGA.js → ReactUpload-DQ0BYISX.js} +1 -1
- package/cjs/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
- package/{esm/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → cjs/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/cjs/{TestTriggers-DbhsNPdg-DjvVuc2h.js → TestTriggers-D29T_R0M-D6Bu-Mln.js} +355 -47
- package/cjs/{UploadController-MLVs97Zt.js → UploadController-l8fZM2qT.js} +34 -14
- package/{esm/WebhookPayload-DkukERKE.d.ts → cjs/WebhookPayload-Dt6DttS0.d.ts} +120 -86
- package/cjs/app.d.ts +6 -7
- package/cjs/app.js +4 -3
- package/cjs/elements.d.ts +123 -22
- package/cjs/elements.js +553 -156
- package/cjs/file-icons.d.ts +2 -67
- package/cjs/index-Bde1wjiw.d.ts +16 -0
- package/cjs/index.d.ts +5 -6
- package/cjs/index.js +3 -2
- package/cjs/react-native.d.ts +52 -11
- package/cjs/react-native.js +231 -99
- package/cjs/react.d.ts +42 -9
- package/cjs/react.js +381 -118
- package/cjs/server.d.ts +48 -7
- package/cjs/server.js +7 -3
- package/cjs/test-inputs.d.ts +2 -2
- package/cjs/test-inputs.js +13 -9
- package/cjs/testing.d.ts +29 -15
- package/cjs/testing.js +1722 -433
- package/cjs/ui-BRA4HQ8r.js +1359 -0
- package/cjs/ui-YQuvbidU.d.ts +139 -0
- package/cjs/ui.d.ts +3 -2
- package/cjs/ui.js +45 -22
- package/cjs/vue.d.ts +802 -199
- package/cjs/vue.js +359 -127
- package/esm/{BrowserUpload-C07aL9Vq.d.ts → BrowserUpload-BWjZ9ntu.d.ts} +2 -2
- package/esm/{BrowserUpload-CAVkRotw.js → BrowserUpload-GRZVB0G_.js} +1 -1
- package/esm/{CalmLensAppClient-PQ9VBvlW.js → CalmLensAppClient-B5QIJ6KS.js} +30 -10
- package/esm/{CalmLensAppClient-DDLojj0P.d.ts → CalmLensAppClient-BaW3ddUR.d.ts} +13 -3
- package/esm/{CalmLensOptionKeys-Do2mPP6w.js → CalmLensOptionKeys-BG7Qrh8-.js} +317 -367
- package/esm/CalmLensServerClient-BKzn8zmp.d.ts +353 -0
- package/esm/{CalmLensServerClient-C_H5aAsV.js → CalmLensServerClient-bRUAebi-.js} +323 -90
- package/esm/{CalmLensTypes-COJbOuiv.d.ts → CalmLensTypes-BDKwThbO.d.ts} +26993 -27187
- package/esm/{Classification-D3SkprrQ-CMnQKW13.d.ts → Classification-Q5zGpR8l-CEWjnE39.d.ts} +731 -607
- package/esm/Core-BvQe4moS.js +846 -0
- package/esm/Core-C33pkBmf.d.ts +826 -0
- package/esm/FileIcons-4qSX7DW2.d.ts +67 -0
- package/esm/{ModerationContextLimits-Chw-AzgL.js → ModerationContextLimits-CrxSnVZ3.js} +682 -253
- package/esm/{ReactUpload-CMmL0R5Q.js → ReactUpload-BMO8saxT.js} +1 -1
- package/esm/{ReactUpload-CRJNPB5T.d.ts → ReactUpload-DhF8mm51.d.ts} +1 -1
- package/{cjs/TestTriggers-D-fwfhEP-hlaP1oW2.d.ts → esm/TestTriggers-D0pYHbkr-D5T0VdSn.d.ts} +146 -8
- package/esm/{TestTriggers-DbhsNPdg-CUdrv8Nm.js → TestTriggers-D29T_R0M-Ztc74ucs.js} +332 -48
- package/esm/{UploadController-BJZghJpg.js → UploadController-DnJrWiE4.js} +34 -14
- package/{cjs/WebhookPayload-DkukERKE.d.ts → esm/WebhookPayload-Dt6DttS0.d.ts} +120 -86
- package/esm/app.d.ts +6 -7
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +123 -22
- package/esm/elements.js +497 -128
- package/esm/file-icons.d.ts +2 -67
- package/esm/index-Bde1wjiw.d.ts +16 -0
- package/esm/index.d.ts +5 -6
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +52 -11
- package/esm/react-native.js +205 -75
- package/esm/react.d.ts +42 -9
- package/esm/react.js +327 -91
- package/esm/server.d.ts +48 -7
- package/esm/server.js +3 -3
- package/esm/styles.css +142 -22
- package/esm/svelte/AssetViewer.svelte +25 -0
- package/esm/svelte/CalmLensAsset.svelte +318 -0
- package/esm/svelte/CalmLensDocumentViewer.svelte +7 -0
- package/esm/svelte/CalmLensImageViewer.svelte +7 -0
- package/esm/svelte/CalmLensSpreadsheetViewer.svelte +7 -0
- package/esm/svelte/CalmLensTextViewer.svelte +7 -0
- package/esm/svelte/CalmLensWebsiteViewer.svelte +7 -0
- package/esm/svelte/index.d.ts +29 -6
- package/esm/svelte/index.js +7 -2
- package/esm/test-inputs.d.ts +2 -2
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +29 -15
- package/esm/testing.js +1718 -429
- package/esm/ui-YQuvbidU.d.ts +139 -0
- package/esm/ui-heryDd6g.js +1258 -0
- package/esm/ui.d.ts +3 -2
- package/esm/ui.js +4 -3
- package/esm/vue.d.ts +802 -199
- package/esm/vue.js +308 -103
- package/package.json +4 -2
- package/cjs/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
- package/cjs/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/cjs/index-DxbJ_Xaa.d.ts +0 -253
- package/cjs/ui-BSqPGKrZ.d.ts +0 -539
- package/cjs/ui-CX1z2pD9.js +0 -586
- package/esm/CalmLensServerClient-C-jsjn8m.d.ts +0 -259
- package/esm/ModerationContext-9lGm-Mna-CcmbRnOy.d.ts +0 -67
- package/esm/index-DxbJ_Xaa.d.ts +0 -253
- package/esm/svelte/CalmLensMedia.svelte +0 -134
- package/esm/ui-BSqPGKrZ.d.ts +0 -539
- package/esm/ui-CXH7xJpb.js +0 -461
|
@@ -1,63 +1,65 @@
|
|
|
1
1
|
// src/client/CalmLensErrorCodes.ts
|
|
2
2
|
/** Error codes the CalmLens API documents, by name. */
|
|
3
3
|
const API_ERROR_CODES = {
|
|
4
|
-
INVALID_VIEWER_CLAIMS: "viewer/invalid
|
|
4
|
+
INVALID_VIEWER_CLAIMS: "viewer-claims/invalid",
|
|
5
5
|
AGE_CONFIRMATION_REQUIRED: "viewer/age-confirmation-required",
|
|
6
|
-
INVALID_VIEWER_REGION: "viewer/invalid
|
|
6
|
+
INVALID_VIEWER_REGION: "viewer-region/invalid",
|
|
7
7
|
VIEWER_REGION_REQUIRED: "viewer/region-required",
|
|
8
8
|
REGIONAL_EVIDENCE_REQUIRED: "asset/regional-evidence-required",
|
|
9
9
|
SIGNED_URL_EXPIRED: "signed-url/expired",
|
|
10
10
|
SIGNED_URL_INVALID: "signed-url/invalid",
|
|
11
|
+
SIGNED_URL_ORIGINAL_NOT_GRANTED: "signed-url/original-not-granted",
|
|
12
|
+
INVALID_REQUEST: "validation/invalid-request",
|
|
11
13
|
INVALID_TYPE: "validation/invalid-type",
|
|
12
14
|
TOO_SMALL: "validation/too-small",
|
|
13
15
|
TOO_BIG: "validation/too-big",
|
|
14
16
|
INVALID_FORMAT: "validation/invalid-format",
|
|
15
17
|
INVALID_VALUE: "validation/invalid-value",
|
|
16
18
|
UNKNOWN_FIELD: "validation/unknown-field",
|
|
17
|
-
UNSUPPORTED_CONTENT_TYPE: "
|
|
18
|
-
INVALID_FILTER: "
|
|
19
|
-
|
|
20
|
-
ROUTE_NOT_FOUND: "
|
|
21
|
-
INTERNAL_ERROR: "
|
|
19
|
+
UNSUPPORTED_CONTENT_TYPE: "request/unsupported-content-type",
|
|
20
|
+
INVALID_FILTER: "filter/invalid",
|
|
21
|
+
UNSUPPORTED_ORDERING_FIELD: "ordering/unsupported-field",
|
|
22
|
+
ROUTE_NOT_FOUND: "request/route-not-found",
|
|
23
|
+
INTERNAL_ERROR: "server/internal-error",
|
|
22
24
|
UNAUTHENTICATED: "auth/unauthenticated",
|
|
23
|
-
TOKEN_EXPIRED: "
|
|
24
|
-
INVALID_TOKEN: "
|
|
25
|
+
TOKEN_EXPIRED: "session-token/expired",
|
|
26
|
+
INVALID_TOKEN: "session-token/invalid",
|
|
25
27
|
SEARCH_UNAVAILABLE: "search/unavailable",
|
|
26
|
-
INVALID_TRANSFORM: "
|
|
27
|
-
INVALID_TRANSFORM_OPTIONS: "
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
API_KEY_PROJECT_MISMATCH: "auth/project-mismatch",
|
|
35
|
-
API_KEY_NOT_ACCEPTED: "auth/api-key-not-accepted",
|
|
28
|
+
INVALID_TRANSFORM: "transform/invalid",
|
|
29
|
+
INVALID_TRANSFORM_OPTIONS: "transform-options/invalid",
|
|
30
|
+
REMOTE_URL_TOO_MANY_REDIRECTS: "remote-url/too-many-redirects",
|
|
31
|
+
INVALID_CURSOR: "cursor/invalid",
|
|
32
|
+
MISSING_API_KEY: "api-key/missing",
|
|
33
|
+
INVALID_API_KEY: "api-key/invalid",
|
|
34
|
+
API_KEY_PROJECT_MISMATCH: "api-key/project-mismatch",
|
|
35
|
+
API_KEY_NOT_ACCEPTED: "api-key/not-accepted",
|
|
36
36
|
PERMISSION_DENIED: "auth/permission-denied",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
UPLOAD_TOO_LARGE: "upload/too-large",
|
|
38
|
+
DOCUMENT_TOO_MANY_ITEMS: "document/too-many-items",
|
|
39
|
+
MEDIA_DURATION_LIMIT: "media/duration-limit",
|
|
40
|
+
INVALID_IMAGE: "image/invalid",
|
|
41
|
+
IMAGE_TOO_LARGE: "image/too-large",
|
|
42
|
+
FREE_UPLOADS_EXHAUSTED: "usage/free-uploads-exhausted",
|
|
43
|
+
UPLOADS_PAUSED: "usage/uploads-paused",
|
|
44
|
+
UNSUPPORTED_UPLOAD_TYPE: "upload/unsupported-type",
|
|
45
|
+
INVALID_UPLOAD_PAYLOAD: "upload-payload/invalid",
|
|
46
|
+
UPLOAD_OPTIONS_IN_QUERY: "upload/options-in-query",
|
|
47
47
|
USE_UPLOAD_PART: "upload/use-upload-part",
|
|
48
48
|
UPLOAD_NOT_OPEN: "upload/not-open",
|
|
49
|
-
INVALID_UPLOAD_PART_NUMBER: "upload/invalid-
|
|
49
|
+
INVALID_UPLOAD_PART_NUMBER: "upload-part/invalid-number",
|
|
50
50
|
UPLOAD_MISSING: "upload/missing",
|
|
51
51
|
UPLOAD_SIZE_MISMATCH: "upload/size-mismatch",
|
|
52
52
|
INVALID_IDEMPOTENCY_KEY: "idempotency/invalid-key",
|
|
53
53
|
IDEMPOTENCY_KEY_REUSED: "idempotency/key-reused",
|
|
54
54
|
IDEMPOTENT_REQUEST_IN_PROGRESS: "idempotency/request-in-progress",
|
|
55
|
+
NO_RENDERED_VERSION: "asset/no-rendered-version",
|
|
55
56
|
ASSET_NOT_FOUND: "asset/not-found",
|
|
56
57
|
PROJECT_NOT_FOUND: "project/not-found",
|
|
58
|
+
ASSET_CHILD_NOT_DELETABLE: "asset/child-not-deletable",
|
|
57
59
|
ASSET_REVIEW_CHANGED: "asset/review-changed",
|
|
58
60
|
ASSET_REVIEW_NOTE_REQUIRED: "asset/review-note-required",
|
|
59
61
|
ASSET_UPDATE_FAILED: "asset/update-failed",
|
|
60
|
-
|
|
62
|
+
ASSET_HELD: "asset/held",
|
|
61
63
|
ASSET_PROCESSING: "asset/processing",
|
|
62
64
|
ASSET_DECISION_NOT_ALLOWED: "asset/decision-not-allowed",
|
|
63
65
|
ASSET_DECISION_UNCHANGED: "asset/decision-unchanged",
|
|
@@ -67,18 +69,19 @@ const API_ERROR_CODES = {
|
|
|
67
69
|
ASSET_NOT_DECIDED: "asset/not-decided",
|
|
68
70
|
ASSET_POLICY_CHANGED: "asset/policy-changed",
|
|
69
71
|
ASSET_REVIEWED: "asset/reviewed",
|
|
70
|
-
SUPPORT_TICKET_NOT_FOUND: "support/
|
|
72
|
+
SUPPORT_TICKET_NOT_FOUND: "support-ticket/not-found",
|
|
71
73
|
DUPLICATE_EXTERNAL_ID: "asset/duplicate-external-id",
|
|
72
74
|
FOLDER_NOT_FOUND: "folder/not-found",
|
|
73
75
|
DUPLICATE_FOLDER_NAME: "folder/duplicate-name",
|
|
74
76
|
FOLDER_NOT_EMPTY: "folder/not-empty",
|
|
75
77
|
FOLDER_PARENT_CYCLE: "folder/parent-cycle",
|
|
76
|
-
|
|
78
|
+
LENS_NOT_FOUND: "lens/not-found",
|
|
79
|
+
LENS_IDENTIFIER_TAKEN: "lens/identifier-taken",
|
|
77
80
|
LENS_IDENTIFIER_RESERVED: "lens/identifier-reserved",
|
|
78
81
|
HASH_LIST_NOT_FOUND: "hash-list/not-found",
|
|
79
|
-
HASH_LIST_ENTRY_NOT_FOUND: "hash-list/
|
|
82
|
+
HASH_LIST_ENTRY_NOT_FOUND: "hash-list-entry/not-found",
|
|
80
83
|
HASH_LIST_LIMIT_REACHED: "hash-list/limit-reached",
|
|
81
|
-
HASH_LIST_ENTRY_LIMIT_REACHED: "hash-list/
|
|
84
|
+
HASH_LIST_ENTRY_LIMIT_REACHED: "hash-list-entry/limit-reached",
|
|
82
85
|
HASH_LIST_ASSET_NOT_HASHED: "hash-list/asset-not-hashed",
|
|
83
86
|
POLICY_NOT_FOUND: "policy/not-found",
|
|
84
87
|
POLICY_REVISION_CONFLICT: "policy/revision-conflict",
|
|
@@ -92,18 +95,24 @@ const API_ERROR_CODES = {
|
|
|
92
95
|
UPLOAD_PRESET_NOT_FOUND: "upload-preset/not-found",
|
|
93
96
|
UPLOAD_PRESET_DISABLED: "upload-preset/disabled",
|
|
94
97
|
UPLOAD_PRESET_TOKEN_REQUIRED: "upload-preset/token-required",
|
|
95
|
-
REMOTE_URL_NOT_ALLOWED: "
|
|
96
|
-
|
|
97
|
-
UPLOAD_PRESET_CONTENT_TYPE_NOT_ALLOWED: "upload-preset/content-type-not-allowed",
|
|
98
|
-
UPLOAD_PRESET_TOO_LARGE: "upload-preset/too-large",
|
|
98
|
+
REMOTE_URL_NOT_ALLOWED: "remote-url/not-allowed",
|
|
99
|
+
WEBSITE_RATE_LIMIT_REACHED: "upload/website-rate-limit-reached",
|
|
99
100
|
UPLOAD_PRESET_DAILY_LIMIT_REACHED: "upload-preset/daily-limit-reached",
|
|
100
101
|
UPLOAD_PRESET_ORIGIN_NOT_ALLOWED: "upload-preset/origin-not-allowed",
|
|
101
102
|
UPLOAD_PRESET_FIELD_NOT_ALLOWED: "upload-preset/field-not-allowed",
|
|
103
|
+
UPLOAD_PRESET_REVISION_CONFLICT: "upload-preset/revision-conflict",
|
|
104
|
+
UPLOAD_PRESET_KEY_TAKEN: "upload-preset/key-taken",
|
|
105
|
+
UPLOAD_PRESET_DAILY_LIMIT_REQUIRED: "upload-preset/daily-limit-required",
|
|
106
|
+
UPLOAD_PRESET_INVALID_FOLDER: "upload-preset/invalid-folder",
|
|
107
|
+
UPLOAD_PRESET_INVALID_POLICY: "upload-preset/invalid-policy",
|
|
108
|
+
PROJECT_SETTINGS_REVISION_CONFLICT: "project-settings/revision-conflict",
|
|
109
|
+
SEARCH_ESTIMATE_CHANGED: "search/estimate-changed",
|
|
110
|
+
METADATA_FIELD_NOT_FOUND: "metadata-field/not-found",
|
|
102
111
|
UPLOAD_TOKEN_INVALID: "upload-token/invalid",
|
|
103
112
|
UPLOAD_TOKEN_EXPIRED: "upload-token/expired",
|
|
104
113
|
UPLOAD_TOKEN_USED: "upload-token/used",
|
|
105
|
-
INVALID_REMOTE_URL: "
|
|
106
|
-
REMOTE_URL_UNAVAILABLE: "
|
|
114
|
+
INVALID_REMOTE_URL: "remote-url/invalid",
|
|
115
|
+
REMOTE_URL_UNAVAILABLE: "remote-url/unavailable",
|
|
107
116
|
APPEAL_NOT_FOUND: "appeal/not-found",
|
|
108
117
|
APPEAL_JUDGMENT_NOT_FOUND: "appeal/judgment-not-found",
|
|
109
118
|
APPEAL_ASSET_NOT_FOUND: "appeal/asset-not-found",
|
|
@@ -111,12 +120,11 @@ const API_ERROR_CODES = {
|
|
|
111
120
|
APPEAL_ALREADY_REVIEWED: "appeal/already-reviewed",
|
|
112
121
|
APPEAL_DECISION_CHANGED: "appeal/decision-changed",
|
|
113
122
|
APPEAL_INVALID_ACTION: "appeal/invalid-action",
|
|
114
|
-
APPEAL_SAFETY_HELD: "appeal/safety-held",
|
|
115
123
|
APPEAL_CONTENT_UNAVAILABLE: "appeal/content-unavailable"
|
|
116
124
|
};
|
|
117
125
|
/** The HTTP status and default message the API returns with each documented error code. */
|
|
118
126
|
const API_ERROR_DEFINITIONS = {
|
|
119
|
-
"viewer/invalid
|
|
127
|
+
"viewer-claims/invalid": {
|
|
120
128
|
status: 400,
|
|
121
129
|
message: "Supply a viewerClaims object with an optional region and boolean ageConfirmed."
|
|
122
130
|
},
|
|
@@ -124,7 +132,7 @@ const API_ERROR_DEFINITIONS = {
|
|
|
124
132
|
status: 403,
|
|
125
133
|
message: "Your application has not confirmed age-restricted delivery for this viewer."
|
|
126
134
|
},
|
|
127
|
-
"viewer/invalid
|
|
135
|
+
"viewer-region/invalid": {
|
|
128
136
|
status: 400,
|
|
129
137
|
message: "Supply the viewer's ISO country code, such as DE or GB."
|
|
130
138
|
},
|
|
@@ -142,49 +150,57 @@ const API_ERROR_DEFINITIONS = {
|
|
|
142
150
|
},
|
|
143
151
|
"signed-url/invalid": {
|
|
144
152
|
status: 403,
|
|
145
|
-
message: "The signed URL's
|
|
153
|
+
message: "The signed asset URL's grant wasn't signed for this project, or was changed after signing. Use the URL as created, adding only resources, selectors and viewer claims."
|
|
154
|
+
},
|
|
155
|
+
"signed-url/original-not-granted": {
|
|
156
|
+
status: 403,
|
|
157
|
+
message: "This signed asset URL doesn't grant the original file. Sign it with original access."
|
|
158
|
+
},
|
|
159
|
+
"validation/invalid-request": {
|
|
160
|
+
status: 400,
|
|
161
|
+
message: "The request's parameters, query or body are invalid. details.issues lists each problem, with its path and issue code."
|
|
146
162
|
},
|
|
147
163
|
"validation/invalid-type": {
|
|
148
164
|
status: 400,
|
|
149
|
-
message: "
|
|
165
|
+
message: "Issue code in details.issues: a field has the wrong type."
|
|
150
166
|
},
|
|
151
167
|
"validation/too-small": {
|
|
152
168
|
status: 400,
|
|
153
|
-
message: "
|
|
169
|
+
message: "Issue code in details.issues: a value is below its minimum."
|
|
154
170
|
},
|
|
155
171
|
"validation/too-big": {
|
|
156
172
|
status: 400,
|
|
157
|
-
message: "
|
|
173
|
+
message: "Issue code in details.issues: a value is above its maximum."
|
|
158
174
|
},
|
|
159
175
|
"validation/invalid-format": {
|
|
160
176
|
status: 400,
|
|
161
|
-
message: "
|
|
177
|
+
message: "Issue code in details.issues: a string is not in the required format, such as an ID or URL."
|
|
162
178
|
},
|
|
163
179
|
"validation/invalid-value": {
|
|
164
180
|
status: 400,
|
|
165
|
-
message: "
|
|
181
|
+
message: "Issue code in details.issues: a field has a value it cannot take."
|
|
166
182
|
},
|
|
167
183
|
"validation/unknown-field": {
|
|
168
184
|
status: 400,
|
|
169
|
-
message: "
|
|
185
|
+
message: "Issue code in details.issues: the request has a field this endpoint does not accept."
|
|
170
186
|
},
|
|
171
|
-
"
|
|
187
|
+
"request/unsupported-content-type": {
|
|
172
188
|
status: 415,
|
|
173
189
|
message: "Send the request body as application/json."
|
|
174
190
|
},
|
|
175
|
-
"
|
|
191
|
+
"filter/invalid": {
|
|
176
192
|
status: 400,
|
|
177
193
|
message: "The filter has invalid syntax or names a field that can't be filtered."
|
|
178
194
|
},
|
|
179
|
-
"
|
|
195
|
+
"ordering/unsupported-field": {
|
|
180
196
|
status: 400,
|
|
181
197
|
message: "The list cannot be ordered by this field."
|
|
182
198
|
},
|
|
183
|
-
"
|
|
199
|
+
"request/route-not-found": {
|
|
184
200
|
status: 404,
|
|
185
201
|
message: "No endpoint matches this method and path."
|
|
186
202
|
},
|
|
187
|
-
"
|
|
203
|
+
"server/internal-error": {
|
|
188
204
|
status: 500,
|
|
189
205
|
message: "An internal error occurred. Retry later, and quote requestId to support."
|
|
190
206
|
},
|
|
@@ -192,11 +208,11 @@ const API_ERROR_DEFINITIONS = {
|
|
|
192
208
|
status: 401,
|
|
193
209
|
message: "Authentication required."
|
|
194
210
|
},
|
|
195
|
-
"
|
|
211
|
+
"session-token/expired": {
|
|
196
212
|
status: 401,
|
|
197
213
|
message: "The session token has expired. Sign in again."
|
|
198
214
|
},
|
|
199
|
-
"
|
|
215
|
+
"session-token/invalid": {
|
|
200
216
|
status: 401,
|
|
201
217
|
message: "The session token is invalid. Sign in again."
|
|
202
218
|
},
|
|
@@ -204,90 +220,82 @@ const API_ERROR_DEFINITIONS = {
|
|
|
204
220
|
status: 503,
|
|
205
221
|
message: "Search is temporarily unavailable. Retry later."
|
|
206
222
|
},
|
|
207
|
-
"
|
|
223
|
+
"transform/invalid": {
|
|
208
224
|
status: 400,
|
|
209
225
|
message: "The transform names an unknown type or is not a valid selector."
|
|
210
226
|
},
|
|
211
|
-
"
|
|
227
|
+
"transform-options/invalid": {
|
|
212
228
|
status: 400,
|
|
213
229
|
message: "The transform's options are invalid for its type."
|
|
214
230
|
},
|
|
215
|
-
"
|
|
231
|
+
"remote-url/too-many-redirects": {
|
|
216
232
|
status: 400,
|
|
217
233
|
message: "The remote URL redirected too many times."
|
|
218
234
|
},
|
|
219
|
-
"
|
|
220
|
-
status: 409,
|
|
221
|
-
message: "The asset's content is held for a copyright claim and cannot be changed."
|
|
222
|
-
},
|
|
223
|
-
"asset/api-key-missing-permission": {
|
|
224
|
-
status: 403,
|
|
225
|
-
message: "This API key needs assets:download permission for this asset's folder."
|
|
226
|
-
},
|
|
227
|
-
"validation/invalid-cursor": {
|
|
235
|
+
"cursor/invalid": {
|
|
228
236
|
status: 400,
|
|
229
237
|
message: "The cursor is invalid or belongs to a different query."
|
|
230
238
|
},
|
|
231
|
-
"
|
|
239
|
+
"api-key/missing": {
|
|
232
240
|
status: 401,
|
|
233
241
|
message: "Authentication required. Send your project API key in the X-Api-Key header."
|
|
234
242
|
},
|
|
235
|
-
"
|
|
243
|
+
"api-key/invalid": {
|
|
236
244
|
status: 401,
|
|
237
245
|
message: "The API key is invalid, revoked or expired. Create a key under Developer → API Keys."
|
|
238
246
|
},
|
|
239
|
-
"
|
|
247
|
+
"api-key/project-mismatch": {
|
|
240
248
|
status: 403,
|
|
241
249
|
message: "This API key belongs to a different project. Use a key created for the project that owns this resource."
|
|
242
250
|
},
|
|
243
|
-
"
|
|
251
|
+
"api-key/not-accepted": {
|
|
244
252
|
status: 403,
|
|
245
253
|
message: "API keys are only accepted by the public API at /v1."
|
|
246
254
|
},
|
|
247
255
|
"auth/permission-denied": {
|
|
248
256
|
status: 403,
|
|
249
|
-
message: "This API key lacks a permission the request needs, such as assets:
|
|
257
|
+
message: "This API key lacks a permission the request needs (details.permission names it, such as assets:download for an asset's folder, and details.role the least role that includes it), or the resource belongs to another project."
|
|
250
258
|
},
|
|
251
|
-
"upload/
|
|
252
|
-
status:
|
|
253
|
-
message: "
|
|
254
|
-
},
|
|
255
|
-
"upload/multipart-image-too-large": {
|
|
256
|
-
status: 400,
|
|
257
|
-
message: "Multipart image uploads cannot exceed 20 MiB."
|
|
259
|
+
"upload/too-large": {
|
|
260
|
+
status: 413,
|
|
261
|
+
message: "The file is larger than allowed. details.limitBytes is the limit, and details.source says whether it is the plan's (`plan`) or the upload preset's (`preset`)."
|
|
258
262
|
},
|
|
259
|
-
"
|
|
260
|
-
status:
|
|
261
|
-
message: "
|
|
263
|
+
"document/too-many-items": {
|
|
264
|
+
status: 422,
|
|
265
|
+
message: "The document holds more embedded images or audio and video files than can be moderated: details.limit is `images` or `media` and details.maximum the most allowed. Split it into smaller documents."
|
|
262
266
|
},
|
|
263
|
-
"
|
|
267
|
+
"media/duration-limit": {
|
|
264
268
|
status: 422,
|
|
265
|
-
message: "The
|
|
269
|
+
message: "The audio or video is longer than allowed: details.durationSeconds is what its file states and details.limitSeconds the limit. Trim it or split it into separate uploads; before billing is set up, setting it up raises the limit."
|
|
266
270
|
},
|
|
267
|
-
"image/
|
|
271
|
+
"image/invalid": {
|
|
268
272
|
status: 422,
|
|
269
|
-
message: "
|
|
273
|
+
message: "The image is corrupt or cannot be decoded. Upload a valid image file."
|
|
270
274
|
},
|
|
271
|
-
"image/
|
|
275
|
+
"image/too-large": {
|
|
272
276
|
status: 422,
|
|
273
|
-
message: "The image exceeds
|
|
277
|
+
message: "The image exceeds a processing limit: details.limit is `bytes`, `pixels` or `dimension`. Reduce its size before uploading."
|
|
274
278
|
},
|
|
275
|
-
"
|
|
279
|
+
"usage/free-uploads-exhausted": {
|
|
276
280
|
status: 403,
|
|
277
|
-
message: "
|
|
281
|
+
message: "This project's organisation has used its free uploads. Set up billing to continue uploading."
|
|
278
282
|
},
|
|
279
|
-
"
|
|
283
|
+
"usage/uploads-paused": {
|
|
280
284
|
status: 402,
|
|
281
285
|
message: "Uploads to this project are paused by its organisation's usage limits. See details.reason; an owner can review them in Billing."
|
|
282
286
|
},
|
|
283
|
-
"upload/
|
|
284
|
-
status:
|
|
285
|
-
message: "
|
|
287
|
+
"upload/unsupported-type": {
|
|
288
|
+
status: 415,
|
|
289
|
+
message: "The file type is not accepted. details.source is `calmlens` when CalmLens cannot store and process it (use a concrete MIME type such as image/png, application/pdf or text/plain) or `preset` when the upload preset doesn't allow it."
|
|
286
290
|
},
|
|
287
|
-
"upload/invalid
|
|
291
|
+
"upload-payload/invalid": {
|
|
288
292
|
status: 400,
|
|
289
293
|
message: "Upload payload is invalid."
|
|
290
294
|
},
|
|
295
|
+
"upload/options-in-query": {
|
|
296
|
+
status: 400,
|
|
297
|
+
message: "Send the asset's name and fields in the request body (the JSON body, or the options part of a multipart/form-data upload), not in the query string."
|
|
298
|
+
},
|
|
291
299
|
"upload/use-upload-part": {
|
|
292
300
|
status: 409,
|
|
293
301
|
message: "Use uploadPart for multipart upload parts after the first part"
|
|
@@ -296,7 +304,7 @@ const API_ERROR_DEFINITIONS = {
|
|
|
296
304
|
status: 409,
|
|
297
305
|
message: "Asset is not accepting additional parts"
|
|
298
306
|
},
|
|
299
|
-
"upload/invalid-
|
|
307
|
+
"upload-part/invalid-number": {
|
|
300
308
|
status: 409,
|
|
301
309
|
message: "Multipart upload part number is invalid."
|
|
302
310
|
},
|
|
@@ -320,6 +328,10 @@ const API_ERROR_DEFINITIONS = {
|
|
|
320
328
|
status: 409,
|
|
321
329
|
message: "A request with this Idempotency-Key is still being processed. Retry after the Retry-After delay to receive its result."
|
|
322
330
|
},
|
|
331
|
+
"asset/no-rendered-version": {
|
|
332
|
+
status: 404,
|
|
333
|
+
message: "This asset has no such resource: text and spreadsheets have no rendered version or preview, and documents, audio and video get theirs once processing makes them. Check the asset's `content.rendered` and `content.preview`, or request its original resource instead."
|
|
334
|
+
},
|
|
323
335
|
"asset/not-found": {
|
|
324
336
|
status: 404,
|
|
325
337
|
message: "Asset not found"
|
|
@@ -328,6 +340,10 @@ const API_ERROR_DEFINITIONS = {
|
|
|
328
340
|
status: 404,
|
|
329
341
|
message: "Project not found"
|
|
330
342
|
},
|
|
343
|
+
"asset/child-not-deletable": {
|
|
344
|
+
status: 409,
|
|
345
|
+
message: "This asset was extracted from another asset (its `parentId`), so it can't be deleted on its own. Delete the asset it was extracted from instead, which deletes it too."
|
|
346
|
+
},
|
|
331
347
|
"asset/review-changed": {
|
|
332
348
|
status: 409,
|
|
333
349
|
message: "The asset changed during review. Refresh and review the current decision."
|
|
@@ -340,9 +356,9 @@ const API_ERROR_DEFINITIONS = {
|
|
|
340
356
|
status: 500,
|
|
341
357
|
message: "Failed to update asset"
|
|
342
358
|
},
|
|
343
|
-
"asset/
|
|
359
|
+
"asset/held": {
|
|
344
360
|
status: 423,
|
|
345
|
-
message: "
|
|
361
|
+
message: "The asset is held and this request can't change or deliver it. details.hold is `safety` for a safety hold or `copyright` for a copyright claim."
|
|
346
362
|
},
|
|
347
363
|
"asset/processing": {
|
|
348
364
|
status: 409,
|
|
@@ -380,7 +396,7 @@ const API_ERROR_DEFINITIONS = {
|
|
|
380
396
|
status: 409,
|
|
381
397
|
message: "A reviewer has decided this asset, so its moderation can't be re-run."
|
|
382
398
|
},
|
|
383
|
-
"support/
|
|
399
|
+
"support-ticket/not-found": {
|
|
384
400
|
status: 404,
|
|
385
401
|
message: "Support ticket not found."
|
|
386
402
|
},
|
|
@@ -404,9 +420,13 @@ const API_ERROR_DEFINITIONS = {
|
|
|
404
420
|
status: 409,
|
|
405
421
|
message: "A folder cannot be moved inside itself or one of its descendants."
|
|
406
422
|
},
|
|
407
|
-
"lens/
|
|
423
|
+
"lens/not-found": {
|
|
424
|
+
status: 404,
|
|
425
|
+
message: "Lens not found. Check the lens ID or identifier in the portal."
|
|
426
|
+
},
|
|
427
|
+
"lens/identifier-taken": {
|
|
408
428
|
status: 409,
|
|
409
|
-
message: "
|
|
429
|
+
message: "The project already has a lens with this identifier. Update that lens, or give this one another identifier."
|
|
410
430
|
},
|
|
411
431
|
"lens/identifier-reserved": {
|
|
412
432
|
status: 409,
|
|
@@ -416,7 +436,7 @@ const API_ERROR_DEFINITIONS = {
|
|
|
416
436
|
status: 404,
|
|
417
437
|
message: "Hash list not found. Check the list ID in the portal."
|
|
418
438
|
},
|
|
419
|
-
"hash-list/
|
|
439
|
+
"hash-list-entry/not-found": {
|
|
420
440
|
status: 404,
|
|
421
441
|
message: "Hash list entry not found."
|
|
422
442
|
},
|
|
@@ -424,7 +444,7 @@ const API_ERROR_DEFINITIONS = {
|
|
|
424
444
|
status: 409,
|
|
425
445
|
message: "This project has the most hash lists it can hold. Delete a list to add another."
|
|
426
446
|
},
|
|
427
|
-
"hash-list/
|
|
447
|
+
"hash-list-entry/limit-reached": {
|
|
428
448
|
status: 409,
|
|
429
449
|
message: "This project's hash lists hold the most entries they can. Remove entries to add more."
|
|
430
450
|
},
|
|
@@ -480,22 +500,14 @@ const API_ERROR_DEFINITIONS = {
|
|
|
480
500
|
status: 401,
|
|
481
501
|
message: "This upload preset only accepts uploads with an upload token. Sign one on your server with uploadTokens.sign and pass it to the client."
|
|
482
502
|
},
|
|
483
|
-
"
|
|
503
|
+
"remote-url/not-allowed": {
|
|
484
504
|
status: 403,
|
|
485
505
|
message: "This project doesn't accept URLs from this domain. Change the allowed or blocked domains under Project settings."
|
|
486
506
|
},
|
|
487
|
-
"upload/website-rate-limit-
|
|
507
|
+
"upload/website-rate-limit-reached": {
|
|
488
508
|
status: 429,
|
|
489
509
|
message: "This project has submitted too many websites in the last minute. Wait for the Retry-After period, or lower the pace of submissions."
|
|
490
510
|
},
|
|
491
|
-
"upload-preset/content-type-not-allowed": {
|
|
492
|
-
status: 415,
|
|
493
|
-
message: "This upload preset doesn't accept this file type."
|
|
494
|
-
},
|
|
495
|
-
"upload-preset/too-large": {
|
|
496
|
-
status: 413,
|
|
497
|
-
message: "This file is larger than the upload preset allows."
|
|
498
|
-
},
|
|
499
511
|
"upload-preset/daily-limit-reached": {
|
|
500
512
|
status: 429,
|
|
501
513
|
message: "You have reached this upload preset's daily upload limit. Try again after midnight UTC."
|
|
@@ -508,6 +520,38 @@ const API_ERROR_DEFINITIONS = {
|
|
|
508
520
|
status: 400,
|
|
509
521
|
message: "This field is set by the upload preset or the upload token and can't be changed by the upload."
|
|
510
522
|
},
|
|
523
|
+
"upload-preset/revision-conflict": {
|
|
524
|
+
status: 409,
|
|
525
|
+
message: "The upload preset changed, or was created or deleted, since you read it. Retrieve it again and retry with its current revision."
|
|
526
|
+
},
|
|
527
|
+
"upload-preset/key-taken": {
|
|
528
|
+
status: 409,
|
|
529
|
+
message: "Another upload preset in this project has this key. Choose a different key."
|
|
530
|
+
},
|
|
531
|
+
"upload-preset/daily-limit-required": {
|
|
532
|
+
status: 400,
|
|
533
|
+
message: "A preset that anyone can upload to needs a daily upload limit."
|
|
534
|
+
},
|
|
535
|
+
"upload-preset/invalid-folder": {
|
|
536
|
+
status: 400,
|
|
537
|
+
message: "The folder isn't in this project. Choose a folder from this project and try again."
|
|
538
|
+
},
|
|
539
|
+
"upload-preset/invalid-policy": {
|
|
540
|
+
status: 400,
|
|
541
|
+
message: "The policy isn't one of this organisation's. Choose one of its policies and try again."
|
|
542
|
+
},
|
|
543
|
+
"project-settings/revision-conflict": {
|
|
544
|
+
status: 409,
|
|
545
|
+
message: "The project's settings or metadata fields changed since you read them. Retrieve them again and retry with the current revision."
|
|
546
|
+
},
|
|
547
|
+
"search/estimate-changed": {
|
|
548
|
+
status: 409,
|
|
549
|
+
message: "Turning on AI media search needs a searchIndexingBudgetUnits of at least the current indexing estimate, which details.indexingUnits gives."
|
|
550
|
+
},
|
|
551
|
+
"metadata-field/not-found": {
|
|
552
|
+
status: 404,
|
|
553
|
+
message: "The project has no metadata field with this ID."
|
|
554
|
+
},
|
|
511
555
|
"upload-token/invalid": {
|
|
512
556
|
status: 401,
|
|
513
557
|
message: "The upload token is invalid. Sign a new one on your server with an active API key for this project."
|
|
@@ -520,11 +564,11 @@ const API_ERROR_DEFINITIONS = {
|
|
|
520
564
|
status: 409,
|
|
521
565
|
message: "The upload token has already been used. Each token uploads one asset."
|
|
522
566
|
},
|
|
523
|
-
"
|
|
567
|
+
"remote-url/invalid": {
|
|
524
568
|
status: 400,
|
|
525
569
|
message: "Remote URLs must use HTTP or HTTPS and cannot target private networks, localhost names or URL credentials."
|
|
526
570
|
},
|
|
527
|
-
"
|
|
571
|
+
"remote-url/unavailable": {
|
|
528
572
|
status: 422,
|
|
529
573
|
message: "The URL responded with an error status. Check that it is publicly reachable."
|
|
530
574
|
},
|
|
@@ -556,10 +600,6 @@ const API_ERROR_DEFINITIONS = {
|
|
|
556
600
|
status: 400,
|
|
557
601
|
message: "The decision's action is not valid for this appeal."
|
|
558
602
|
},
|
|
559
|
-
"appeal/safety-held": {
|
|
560
|
-
status: 409,
|
|
561
|
-
message: "A safety hold prevents this appeal from being submitted or applied."
|
|
562
|
-
},
|
|
563
603
|
"appeal/content-unavailable": {
|
|
564
604
|
status: 409,
|
|
565
605
|
message: "The appeal's content is unavailable, or the asset's content was purged, so it can only be blocked."
|
|
@@ -597,8 +637,9 @@ const CALMLENS_ERROR_CODES = {
|
|
|
597
637
|
...SDK_ERROR_CODES
|
|
598
638
|
};
|
|
599
639
|
const BRAND = Symbol.for("calmlens.sdk.CalmLensError");
|
|
600
|
-
const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
640
|
+
const RETRYABLE_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
601
641
|
429,
|
|
642
|
+
500,
|
|
602
643
|
502,
|
|
603
644
|
503,
|
|
604
645
|
504
|
|
@@ -637,18 +678,27 @@ var CalmLensError = class CalmLensError extends Error {
|
|
|
637
678
|
static [Symbol.hasInstance](value) {
|
|
638
679
|
return CalmLensError.isCalmLensError(value);
|
|
639
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Whether the SDK raised this error itself, with no HTTP response: before sending (an invalid
|
|
683
|
+
* argument or option, or content it checks first, such as `upload/unsupported-type`), or because
|
|
684
|
+
* no response arrived (a timeout, a cancellation or a connection failure). The code is the one
|
|
685
|
+
* the API would use; there is no `status` or `requestId`, so branch on `code`.
|
|
686
|
+
*/
|
|
687
|
+
isLocal() {
|
|
688
|
+
return this.status === void 0;
|
|
689
|
+
}
|
|
640
690
|
/** The resource does not exist or is not visible to this API key. */
|
|
641
691
|
isNotFound() {
|
|
642
692
|
return this.status === 404;
|
|
643
693
|
}
|
|
644
694
|
/**
|
|
645
695
|
* Whether repeating the same request may succeed: transport failures, timeouts (a request's
|
|
646
|
-
* `timeoutMs` or `waitForDecision`'s deadline), throttling (429), gateway errors (502, 503, 504)
|
|
696
|
+
* `timeoutMs` or `waitForDecision`'s deadline), throttling (429), internal and gateway errors (500, 502, 503, 504)
|
|
647
697
|
* and idempotent requests still in progress. Only repeat a create or upload with the same
|
|
648
698
|
* `idempotencyKey`.
|
|
649
699
|
*/
|
|
650
700
|
isRetryable() {
|
|
651
|
-
return RETRYABLE_CODES.has(this.code) || this.status !== void 0 && RETRYABLE_STATUSES.has(this.status);
|
|
701
|
+
return RETRYABLE_CODES.has(this.code) || this.status !== void 0 && RETRYABLE_STATUSES$1.has(this.status);
|
|
652
702
|
}
|
|
653
703
|
};
|
|
654
704
|
const invalidArgument = (message, details) => new CalmLensError(SDK_ERROR_CODES.INVALID_ARGUMENT, {
|
|
@@ -656,6 +706,304 @@ const invalidArgument = (message, details) => new CalmLensError(SDK_ERROR_CODES.
|
|
|
656
706
|
details
|
|
657
707
|
});
|
|
658
708
|
const invalidConfig = (message) => new CalmLensError(SDK_ERROR_CODES.INVALID_CONFIG, { message });
|
|
709
|
+
// src/client/CalmLensVersion.ts
|
|
710
|
+
/** This SDK's version, from its package.json. */
|
|
711
|
+
const SDK_VERSION = "0.22.0";
|
|
712
|
+
const runtimeName = () => {
|
|
713
|
+
const runtime = globalThis;
|
|
714
|
+
if (isReactNativeRuntime()) return "react-native";
|
|
715
|
+
if (runtime.Bun?.version) return `bun/${runtime.Bun.version}`;
|
|
716
|
+
if (runtime.Deno?.version?.deno) return `deno/${runtime.Deno.version.deno}`;
|
|
717
|
+
if (runtime.navigator?.userAgent === "Cloudflare-Workers") return "workerd";
|
|
718
|
+
if (runtime.process?.versions?.node) return `node/${runtime.process.versions.node}`;
|
|
719
|
+
return "unknown";
|
|
720
|
+
};
|
|
721
|
+
/** The `User-Agent` the SDK sends from server runtimes, e.g. `calmlens-js/0.10.0 (node/22.12.0)`. */
|
|
722
|
+
const getUserAgent = () => `calmlens-js/${SDK_VERSION} (${runtimeName()})`;
|
|
723
|
+
/** True in a web page, where API keys would be visible to every visitor. */
|
|
724
|
+
const isBrowserRuntime = () => typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
725
|
+
/** True in a React Native app, where an API key ships inside the app for anyone to extract. */
|
|
726
|
+
const isReactNativeRuntime = () => globalThis.navigator?.product === "ReactNative";
|
|
727
|
+
const RETRY_MAX_DELAY_MS = 8e3;
|
|
728
|
+
const RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
729
|
+
429,
|
|
730
|
+
500,
|
|
731
|
+
502,
|
|
732
|
+
503,
|
|
733
|
+
504
|
|
734
|
+
]);
|
|
735
|
+
const timeoutReason = () => {
|
|
736
|
+
const reason = /* @__PURE__ */ new Error("The operation timed out.");
|
|
737
|
+
reason.name = "TimeoutError";
|
|
738
|
+
return reason;
|
|
739
|
+
};
|
|
740
|
+
/**
|
|
741
|
+
* Links the callers' signals and a per-attempt deadline. `AbortSignal.any` holds its sources
|
|
742
|
+
* weakly, so a long-lived caller signal doesn't collect a listener per streamed response;
|
|
743
|
+
* runtimes without it get explicit listeners that `release` removes.
|
|
744
|
+
*/
|
|
745
|
+
const createAttemptSignal = (signals, timeoutMs) => {
|
|
746
|
+
const callers = signals.filter((signal) => signal !== void 0);
|
|
747
|
+
const deadline = new AbortController();
|
|
748
|
+
let timedOut = false;
|
|
749
|
+
let signal;
|
|
750
|
+
let onAbort;
|
|
751
|
+
if (typeof AbortSignal.any === "function") signal = AbortSignal.any([...callers, deadline.signal]);
|
|
752
|
+
else {
|
|
753
|
+
const controller = new AbortController();
|
|
754
|
+
signal = controller.signal;
|
|
755
|
+
onAbort = (event) => controller.abort(event.target.reason);
|
|
756
|
+
for (const source of [...callers, deadline.signal]) if (source.aborted) controller.abort(source.reason);
|
|
757
|
+
else source.addEventListener("abort", onAbort, { once: true });
|
|
758
|
+
}
|
|
759
|
+
let timer = timeoutMs === void 0 ? void 0 : setTimeout(() => {
|
|
760
|
+
timedOut = true;
|
|
761
|
+
deadline.abort(timeoutReason());
|
|
762
|
+
}, timeoutMs);
|
|
763
|
+
return {
|
|
764
|
+
signal,
|
|
765
|
+
isTimedOut: () => timedOut,
|
|
766
|
+
isCancelled: () => callers.some((caller) => caller.aborted),
|
|
767
|
+
clearDeadline: () => {
|
|
768
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
769
|
+
timer = void 0;
|
|
770
|
+
},
|
|
771
|
+
release: () => {
|
|
772
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
773
|
+
timer = void 0;
|
|
774
|
+
if (onAbort) for (const caller of callers) caller.removeEventListener("abort", onAbort);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
/**
|
|
779
|
+
* A redirect the SDK must not follow: it would send the API key to another origin. Browsers report
|
|
780
|
+
* a manual redirect as an opaque response; other runtimes return the 3xx with its Location.
|
|
781
|
+
*/
|
|
782
|
+
const isRedirect = (response) => response.type === "opaqueredirect" || response.status >= 300 && response.status < 400 && response.headers.has("location");
|
|
783
|
+
/** Turns anything thrown while sending or reading a request into a `CalmLensError`. */
|
|
784
|
+
const toFailure = (cause, attempt) => {
|
|
785
|
+
if (CalmLensError.isCalmLensError(cause)) return cause;
|
|
786
|
+
if (attempt.isCancelled()) return new CalmLensError(SDK_ERROR_CODES.CANCELLED, {
|
|
787
|
+
message: "Request cancelled",
|
|
788
|
+
cause
|
|
789
|
+
});
|
|
790
|
+
if (attempt.isTimedOut()) return new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
|
|
791
|
+
message: "Request timed out",
|
|
792
|
+
cause
|
|
793
|
+
});
|
|
794
|
+
return new CalmLensError(SDK_ERROR_CODES.TRANSPORT_ERROR, {
|
|
795
|
+
message: "Request failed",
|
|
796
|
+
cause
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
const sleep = (ms, signal) => new Promise((resolve, reject) => {
|
|
800
|
+
if (signal?.aborted) {
|
|
801
|
+
reject(new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" }));
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
const onAbort = () => {
|
|
805
|
+
clearTimeout(timer);
|
|
806
|
+
reject(new CalmLensError(SDK_ERROR_CODES.CANCELLED, { message: "Request cancelled" }));
|
|
807
|
+
};
|
|
808
|
+
const timer = setTimeout(() => {
|
|
809
|
+
signal?.removeEventListener("abort", onAbort);
|
|
810
|
+
resolve();
|
|
811
|
+
}, ms);
|
|
812
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
813
|
+
});
|
|
814
|
+
/** Exponential backoff with jitter: half the delay is fixed, the other half random. */
|
|
815
|
+
const getRetryDelayMs = (attempt, random = Math.random) => {
|
|
816
|
+
const delay = Math.min(RETRY_MAX_DELAY_MS, 500 * 2 ** attempt);
|
|
817
|
+
return Math.round(delay / 2 + random() * (delay / 2));
|
|
818
|
+
};
|
|
819
|
+
/** Parses `Retry-After` as seconds or an HTTP date, in seconds from `now`. */
|
|
820
|
+
const parseRetryAfter = (value, now = Date.now()) => {
|
|
821
|
+
if (!value) return void 0;
|
|
822
|
+
const trimmed = value.trim();
|
|
823
|
+
if (/^\d+$/.test(trimmed)) return Number(trimmed);
|
|
824
|
+
const date = Date.parse(trimmed);
|
|
825
|
+
if (Number.isNaN(date)) return void 0;
|
|
826
|
+
return Math.max(0, Math.ceil((date - now) / 1e3));
|
|
827
|
+
};
|
|
828
|
+
/** Bodies that can be sent again unchanged. Streams are consumed by the first attempt. */
|
|
829
|
+
const isReplayableBody = (body) => body === void 0 || body === null || typeof body === "string" || body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || body instanceof URLSearchParams;
|
|
830
|
+
const isApiErrorPayload = (value) => !!value && typeof value === "object" && typeof value.code === "string";
|
|
831
|
+
/** Reads at most `limit` bytes of a body, failing with `sdk/response-too-large` beyond that. */
|
|
832
|
+
const readBody = async (response, limit) => {
|
|
833
|
+
const declared = Number(response.headers.get("content-length"));
|
|
834
|
+
const tooLarge = () => new CalmLensError(SDK_ERROR_CODES.RESPONSE_TOO_LARGE, {
|
|
835
|
+
message: `Response body exceeds ${limit} bytes`,
|
|
836
|
+
status: response.status,
|
|
837
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
838
|
+
headers: response.headers
|
|
839
|
+
});
|
|
840
|
+
if (Number.isFinite(declared) && declared > limit) {
|
|
841
|
+
await response.body?.cancel().catch(() => {});
|
|
842
|
+
throw tooLarge();
|
|
843
|
+
}
|
|
844
|
+
if (!response.body) return /* @__PURE__ */ new Uint8Array(0);
|
|
845
|
+
const reader = response.body.getReader();
|
|
846
|
+
const chunks = [];
|
|
847
|
+
let total = 0;
|
|
848
|
+
for (;;) {
|
|
849
|
+
const { done, value } = await reader.read();
|
|
850
|
+
if (done) break;
|
|
851
|
+
total += value.byteLength;
|
|
852
|
+
if (total > limit) {
|
|
853
|
+
await reader.cancel().catch(() => {});
|
|
854
|
+
throw tooLarge();
|
|
855
|
+
}
|
|
856
|
+
chunks.push(value);
|
|
857
|
+
}
|
|
858
|
+
const bytes = new Uint8Array(total);
|
|
859
|
+
let offset = 0;
|
|
860
|
+
for (const chunk of chunks) {
|
|
861
|
+
bytes.set(chunk, offset);
|
|
862
|
+
offset += chunk.byteLength;
|
|
863
|
+
}
|
|
864
|
+
return bytes;
|
|
865
|
+
};
|
|
866
|
+
const responseInfo = (response) => ({
|
|
867
|
+
status: response.status,
|
|
868
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
869
|
+
headers: response.headers,
|
|
870
|
+
retryAfter: parseRetryAfter(response.headers.get("retry-after"))
|
|
871
|
+
});
|
|
872
|
+
/** The `CalmLensError` for a non-2xx response whose body has been read. */
|
|
873
|
+
const toHttpError = (response, bytes) => {
|
|
874
|
+
let data;
|
|
875
|
+
try {
|
|
876
|
+
data = JSON.parse(new TextDecoder().decode(bytes));
|
|
877
|
+
} catch {}
|
|
878
|
+
if (isApiErrorPayload(data)) {
|
|
879
|
+
const { code, message, details, requestId } = data;
|
|
880
|
+
const info = responseInfo(response);
|
|
881
|
+
return new CalmLensError(code, {
|
|
882
|
+
message: message ?? code,
|
|
883
|
+
...info,
|
|
884
|
+
requestId: info.requestId ?? (typeof requestId === "string" ? requestId : void 0),
|
|
885
|
+
details
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
return new CalmLensError(SDK_ERROR_CODES.HTTP_ERROR, {
|
|
889
|
+
message: `HTTP ${response.status}`,
|
|
890
|
+
...responseInfo(response)
|
|
891
|
+
});
|
|
892
|
+
};
|
|
893
|
+
/** Sends requests with the client's credentials, deadlines, retries and response limits. */
|
|
894
|
+
var CalmLensTransport = class {
|
|
895
|
+
constructor(settings) {
|
|
896
|
+
this.settings = settings;
|
|
897
|
+
this.sleep = settings.sleep ?? sleep;
|
|
898
|
+
}
|
|
899
|
+
headersFor(request) {
|
|
900
|
+
const headers = new Headers(request.init?.headers);
|
|
901
|
+
for (const [name, value] of Object.entries(request.headers ?? {})) headers.set(name, value);
|
|
902
|
+
if (!headers.has("accept") && request.deadline === "body") headers.set("accept", "application/json");
|
|
903
|
+
if (this.settings.apiKey) headers.set("x-api-key", this.settings.apiKey);
|
|
904
|
+
if (!isBrowserRuntime()) headers.set("user-agent", getUserAgent());
|
|
905
|
+
if (request.idempotencyKey) headers.set("idempotency-key", request.idempotencyKey);
|
|
906
|
+
return Object.fromEntries(headers.entries());
|
|
907
|
+
}
|
|
908
|
+
canRetry(request) {
|
|
909
|
+
return this.settings.maxRetries > 0 && (request.method === "GET" || request.method === "HEAD" || !!request.idempotencyKey) && isReplayableBody(request.body);
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
* Sends a request and returns the response, retrying transport failures, timeouts, 429, 500, 502–504 and
|
|
913
|
+
* `idempotency/request-in-progress` when the request is safe to repeat. Non-2xx responses
|
|
914
|
+
* throw unless `allowHttpErrors` is set. Call `release` once the body has been read.
|
|
915
|
+
*/
|
|
916
|
+
async send(request, { allowHttpErrors = false } = {}) {
|
|
917
|
+
const fetchImpl = request.fetch ?? this.settings.fetch;
|
|
918
|
+
const retryable = this.canRetry(request);
|
|
919
|
+
const headers = this.headersFor(request);
|
|
920
|
+
for (let attemptNumber = 0;; attemptNumber++) {
|
|
921
|
+
const canRetryAgain = retryable && attemptNumber < this.settings.maxRetries;
|
|
922
|
+
const attempt = createAttemptSignal([this.settings.signal, request.init?.signal ?? void 0], request.timeoutMs);
|
|
923
|
+
let response;
|
|
924
|
+
try {
|
|
925
|
+
if (attempt.signal.aborted) throw attempt.signal.reason;
|
|
926
|
+
response = await fetchImpl(request.url, {
|
|
927
|
+
...request.init,
|
|
928
|
+
method: request.method,
|
|
929
|
+
headers,
|
|
930
|
+
body: request.body,
|
|
931
|
+
redirect: "manual",
|
|
932
|
+
signal: attempt.signal,
|
|
933
|
+
duplex: "half"
|
|
934
|
+
});
|
|
935
|
+
if (isRedirect(response)) {
|
|
936
|
+
await response.body?.cancel().catch(() => {});
|
|
937
|
+
throw new CalmLensError(SDK_ERROR_CODES.HTTP_ERROR, {
|
|
938
|
+
message: `Unexpected redirect (HTTP ${response.status})`,
|
|
939
|
+
...responseInfo(response),
|
|
940
|
+
status: response.status || void 0
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
} catch (cause) {
|
|
944
|
+
attempt.release();
|
|
945
|
+
const failure = toFailure(cause, attempt);
|
|
946
|
+
if (canRetryAgain && failure.isRetryable()) {
|
|
947
|
+
await this.sleep(getRetryDelayMs(attemptNumber), this.settings.signal);
|
|
948
|
+
continue;
|
|
949
|
+
}
|
|
950
|
+
throw failure;
|
|
951
|
+
}
|
|
952
|
+
if (request.deadline === "headers") attempt.clearDeadline();
|
|
953
|
+
if (response.ok) return {
|
|
954
|
+
response,
|
|
955
|
+
attempt
|
|
956
|
+
};
|
|
957
|
+
if (allowHttpErrors) {
|
|
958
|
+
const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
|
|
959
|
+
const delayMs = retryAfter !== void 0 ? retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
960
|
+
if (!canRetryAgain || !RETRYABLE_STATUSES.has(response.status) || delayMs > 6e4) return {
|
|
961
|
+
response,
|
|
962
|
+
attempt
|
|
963
|
+
};
|
|
964
|
+
attempt.release();
|
|
965
|
+
await response.body?.cancel().catch(() => {});
|
|
966
|
+
await this.sleep(delayMs, this.settings.signal);
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
let error;
|
|
970
|
+
try {
|
|
971
|
+
error = toHttpError(response, await readBody(response, this.settings.maxResponseBytes));
|
|
972
|
+
} catch (cause) {
|
|
973
|
+
error = toFailure(cause, attempt);
|
|
974
|
+
} finally {
|
|
975
|
+
attempt.release();
|
|
976
|
+
}
|
|
977
|
+
const retryDelayMs = error.retryAfter !== void 0 ? error.retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
978
|
+
if (canRetryAgain && retryDelayMs <= 6e4 && error.isRetryable()) {
|
|
979
|
+
await this.sleep(retryDelayMs, this.settings.signal);
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
throw error;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
/** Sends a request and parses its JSON response body. */
|
|
986
|
+
async json(request) {
|
|
987
|
+
const { response, attempt } = await this.send(request);
|
|
988
|
+
try {
|
|
989
|
+
const bytes = await readBody(response, this.settings.maxResponseBytes);
|
|
990
|
+
if (bytes.byteLength === 0 && (response.status === 204 || request.method === "DELETE")) return;
|
|
991
|
+
try {
|
|
992
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
993
|
+
} catch (cause) {
|
|
994
|
+
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
995
|
+
message: `Invalid JSON response (HTTP ${response.status})`,
|
|
996
|
+
...responseInfo(response),
|
|
997
|
+
cause
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
} catch (cause) {
|
|
1001
|
+
throw toFailure(cause, attempt);
|
|
1002
|
+
} finally {
|
|
1003
|
+
attempt.release();
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
659
1007
|
// src/contract/SharedConstants-DxUCZwLZ.js
|
|
660
1008
|
const IMPERSONATION_COOKIE_NAME = "CL_impersonation";
|
|
661
1009
|
const DAY_MS = 864e5;
|
|
@@ -1028,6 +1376,14 @@ const UPLOAD_MIME_TYPES = [
|
|
|
1028
1376
|
"application/msword",
|
|
1029
1377
|
"application/rtf",
|
|
1030
1378
|
"application/vnd.oasis.opendocument.text",
|
|
1379
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
1380
|
+
"application/vnd.ms-excel.sheet.macroenabled.12",
|
|
1381
|
+
"application/vnd.ms-excel",
|
|
1382
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
1383
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
1384
|
+
"application/vnd.ms-powerpoint.presentation.macroenabled.12",
|
|
1385
|
+
"application/vnd.ms-powerpoint",
|
|
1386
|
+
"application/vnd.oasis.opendocument.presentation",
|
|
1031
1387
|
"application/javascript",
|
|
1032
1388
|
"application/json",
|
|
1033
1389
|
"application/x-javascript",
|
|
@@ -1035,26 +1391,6 @@ const UPLOAD_MIME_TYPES = [
|
|
|
1035
1391
|
"application/xml",
|
|
1036
1392
|
"application/yaml"
|
|
1037
1393
|
];
|
|
1038
|
-
// src/client/CalmLensViewerClaims.ts
|
|
1039
|
-
/** The ISO 3166-1 alpha-2 countries a viewer's `region` can be. EU is not a viewer country. */
|
|
1040
|
-
const VIEWER_COUNTRIES = new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
|
|
1041
|
-
/** The European Union's member countries, which the `EU` jurisdiction covers. */
|
|
1042
|
-
const EU_COUNTRIES = new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
|
|
1043
|
-
/**
|
|
1044
|
-
* The claims to send, with `region` and `ageConfirmed` in that order, or `undefined` when the
|
|
1045
|
-
* value isn't an object of only a viewer country `region` and a boolean `ageConfirmed`.
|
|
1046
|
-
*/
|
|
1047
|
-
const parseViewerClaims = (value) => {
|
|
1048
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1049
|
-
const { region, ageConfirmed, ...rest } = value;
|
|
1050
|
-
if (Object.keys(rest).length) return void 0;
|
|
1051
|
-
if (region !== void 0 && (typeof region !== "string" || !VIEWER_COUNTRIES.has(region))) return void 0;
|
|
1052
|
-
if (ageConfirmed !== void 0 && typeof ageConfirmed !== "boolean") return void 0;
|
|
1053
|
-
return {
|
|
1054
|
-
...region !== void 0 && { region },
|
|
1055
|
-
...ageConfirmed !== void 0 && { ageConfirmed }
|
|
1056
|
-
};
|
|
1057
|
-
};
|
|
1058
1394
|
// src/client/CalmLensUtils.ts
|
|
1059
1395
|
const assertHttpUrl = (name, value) => {
|
|
1060
1396
|
if (value === void 0) return;
|
|
@@ -1103,6 +1439,8 @@ const validateAppClientOptions = (options) => {
|
|
|
1103
1439
|
if ("apiKey" in options && options.apiKey !== void 0) throw invalidConfig("CalmLensAppClient never takes an API key, which anyone using the browser or app could read. Upload through uploadPresetId, and keep the API key in CalmLensServerClient on your server.");
|
|
1104
1440
|
if (!options.uploadPresetId) throw invalidConfig("Upload preset ID is required");
|
|
1105
1441
|
configPathSegment(options.uploadPresetId, "Upload preset ID");
|
|
1442
|
+
if (options.projectId !== void 0) configPathSegment(options.projectId, "Project ID");
|
|
1443
|
+
assertHttpUrl("cdnBaseUrl", options.cdnBaseUrl);
|
|
1106
1444
|
if (options.token !== void 0 && typeof options.token !== "string" && typeof options.token !== "function") throw invalidConfig("token must be a string or a function that returns one");
|
|
1107
1445
|
validateConnectionOptions(options);
|
|
1108
1446
|
};
|
|
@@ -1112,6 +1450,16 @@ const validateRequestOptions = (options) => {
|
|
|
1112
1450
|
assertInteger("uploadTimeoutMs", options.uploadTimeoutMs, 1);
|
|
1113
1451
|
assertInteger("maxRetries", options.maxRetries, 0);
|
|
1114
1452
|
};
|
|
1453
|
+
/** The options that name an asset's CDN URL and a resource beneath it. */
|
|
1454
|
+
const CDN_LOCATION_KEYS = [
|
|
1455
|
+
"assetId",
|
|
1456
|
+
"externalId",
|
|
1457
|
+
"lens",
|
|
1458
|
+
"projectId",
|
|
1459
|
+
"resource",
|
|
1460
|
+
"transform",
|
|
1461
|
+
"viewerClaims"
|
|
1462
|
+
];
|
|
1115
1463
|
/**
|
|
1116
1464
|
* Option keys of methods that send no request of their own, or that take keys of their own beside
|
|
1117
1465
|
* a request's; CalmLensOptionKeys, generated from the API, has the rest.
|
|
@@ -1122,23 +1470,10 @@ const LOCAL_OPTION_KEYS = {
|
|
|
1122
1470
|
"signal",
|
|
1123
1471
|
"timeoutMs"
|
|
1124
1472
|
],
|
|
1125
|
-
"cdn.getAssetUrl":
|
|
1126
|
-
|
|
1127
|
-
"lens",
|
|
1128
|
-
"resource",
|
|
1129
|
-
"transform",
|
|
1130
|
-
"viewerClaims"
|
|
1131
|
-
],
|
|
1132
|
-
"cdn.serve": [
|
|
1133
|
-
"assetIdentifier",
|
|
1134
|
-
"init",
|
|
1135
|
-
"lens",
|
|
1136
|
-
"resource",
|
|
1137
|
-
"transform",
|
|
1138
|
-
"viewerClaims"
|
|
1139
|
-
],
|
|
1473
|
+
"cdn.getAssetUrl": CDN_LOCATION_KEYS,
|
|
1474
|
+
"cdn.serve": [...CDN_LOCATION_KEYS, "init"],
|
|
1140
1475
|
"uploadTokens.sign": [
|
|
1141
|
-
"
|
|
1476
|
+
"expiresIn",
|
|
1142
1477
|
"externalId",
|
|
1143
1478
|
"uploadPresetId"
|
|
1144
1479
|
]
|
|
@@ -1204,7 +1539,7 @@ const encodePathSegment = (value, name) => {
|
|
|
1204
1539
|
/**
|
|
1205
1540
|
* Whether the API accepts an upload of this MIME type: an image, audio, video, text, document or
|
|
1206
1541
|
* website type, not a container such as `application/octet-stream`. It refuses any other type with
|
|
1207
|
-
* `upload/
|
|
1542
|
+
* `upload/unsupported-type`.
|
|
1208
1543
|
*/
|
|
1209
1544
|
const isAcceptedUploadMimeType = (mimeType) => {
|
|
1210
1545
|
const type = normalizeUploadMimeType(mimeType);
|
|
@@ -1285,7 +1620,7 @@ const checkTransformOptions = (options) => {
|
|
|
1285
1620
|
* CDN does (packages/shared/src/TransformSelector.ts): an optional first `@lens`, then `key=value`
|
|
1286
1621
|
* options with dotted keys for nested ones (a bare key is `true`). Values are numbers, `true`,
|
|
1287
1622
|
* `false`, hex colours (`#` added) for colour options, or text. Throws on anything the CDN refuses
|
|
1288
|
-
* as `
|
|
1623
|
+
* as `transform/invalid`. Used by the mock CDN.
|
|
1289
1624
|
*/
|
|
1290
1625
|
const parseTransformSelector = (selector) => {
|
|
1291
1626
|
if (!selector) return {};
|
|
@@ -1366,13 +1701,6 @@ const transformSelector = (transform) => {
|
|
|
1366
1701
|
return transform;
|
|
1367
1702
|
};
|
|
1368
1703
|
const DEFAULT_CDN_BASE_URL = `https://cdn.${DOMAIN}/v1`;
|
|
1369
|
-
const CDN_RESOURCES = /* @__PURE__ */ new Set([
|
|
1370
|
-
"original",
|
|
1371
|
-
"rendered",
|
|
1372
|
-
"placeholder"
|
|
1373
|
-
]);
|
|
1374
|
-
/** The longest signed URL lifetime the API accepts: 24 hours. */
|
|
1375
|
-
const MAX_SIGNED_URL_SECONDS = 86400;
|
|
1376
1704
|
/** The operations `assets.batch` runs. */
|
|
1377
1705
|
const ASSET_BATCH_OPERATIONS = ["delete", "remove-content"];
|
|
1378
1706
|
/** Refuses a batch the API would reject for its size, an ID or the operation. */
|
|
@@ -1381,79 +1709,27 @@ const validateBatchAssetsOptions = ({ assetIds, operation }) => {
|
|
|
1381
1709
|
if (assetIds.some((assetId) => typeof assetId !== "string" || !assetId)) throw invalidArgument("Every asset ID must be a non-empty string");
|
|
1382
1710
|
if (!ASSET_BATCH_OPERATIONS.includes(operation)) throw invalidArgument(`operation must be one of ${ASSET_BATCH_OPERATIONS.join(", ")}`);
|
|
1383
1711
|
};
|
|
1384
|
-
const validateSignedUrlOptions = (options) => {
|
|
1385
|
-
const { resource = "rendered", lens, transform, expiresInSeconds } = options;
|
|
1386
|
-
if (resource !== "original" && resource !== "rendered") throw invalidArgument("A signed URL's resource must be original or rendered");
|
|
1387
|
-
if (resource === "original" && (lens !== void 0 || transform !== void 0)) throw invalidArgument("Lenses and transforms apply only to the rendered resource");
|
|
1388
|
-
if (expiresInSeconds !== void 0 && (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 1 || expiresInSeconds > MAX_SIGNED_URL_SECONDS)) throw invalidArgument("expiresInSeconds must be a whole number from 1 to 86400");
|
|
1389
|
-
};
|
|
1390
1712
|
/**
|
|
1391
|
-
*
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
* `resource` is `rendered` (default), `original` or `placeholder`. Only `rendered` takes a lens or
|
|
1395
|
-
* transform, and it serves images in the best format the browser accepts. A
|
|
1396
|
-
* placeholder is a small blurred PNG that the CDN serves publicly for every asset whatever its
|
|
1397
|
-
* visibility or moderation status, without requiring age confirmation.
|
|
1713
|
+
* Serialises a query object the way the API reads it: plain values as text, lists of IDs and enum
|
|
1714
|
+
* values comma-separated, and structured values as JSON. Every key and value is percent-encoded
|
|
1715
|
+
* and missing values are omitted.
|
|
1398
1716
|
*/
|
|
1399
|
-
const
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return appendCdnSelector(url, options);
|
|
1405
|
-
};
|
|
1717
|
+
const stringifyQuery = (query) => Object.entries(query).flatMap(([key, value]) => {
|
|
1718
|
+
if (value === void 0 || value === null) return [];
|
|
1719
|
+
const text = Array.isArray(value) ? value.every((item) => typeof item === "string" || typeof item === "number") ? value.join(",") : JSON.stringify(value) : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
1720
|
+
return [`${encodeURIComponent(key)}=${encodeURIComponent(text)}`];
|
|
1721
|
+
}).join("&");
|
|
1406
1722
|
/**
|
|
1407
|
-
*
|
|
1408
|
-
*
|
|
1723
|
+
* Whether an asset is settled: its `classification.status` is `completed` (moderation decided it)
|
|
1724
|
+
* or `failed`. `assets.waitForDecision` returns at the first such state.
|
|
1409
1725
|
*/
|
|
1410
|
-
const
|
|
1411
|
-
const path = appendCdnPathSelector(url, options);
|
|
1412
|
-
const query = new URLSearchParams();
|
|
1413
|
-
if (options.viewerClaims !== void 0) {
|
|
1414
|
-
const claims = parseViewerClaims(options.viewerClaims);
|
|
1415
|
-
if (!claims) throw invalidArgument("Invalid viewerClaims");
|
|
1416
|
-
query.set("viewerClaims", JSON.stringify(claims));
|
|
1417
|
-
}
|
|
1418
|
-
return query.size ? `${path}?${query}` : path;
|
|
1419
|
-
};
|
|
1420
|
-
const appendCdnPathSelector = (url, options) => {
|
|
1421
|
-
const transform = transformSelector(options.transform);
|
|
1422
|
-
const selector = [...options.lens ? [`@${encodePathSegment(options.lens, "Lens")}`] : [], ...transform ? [typeof options.transform === "string" ? encodeURI(transform) : transform] : []].join(",");
|
|
1423
|
-
return selector ? `${url}/${selector}` : url;
|
|
1424
|
-
};
|
|
1425
|
-
const appendQueryValue = (parts, key, value) => {
|
|
1426
|
-
if (value === void 0 || value === null) return;
|
|
1427
|
-
if (Array.isArray(value)) {
|
|
1428
|
-
for (const [index, item] of value.entries()) appendQueryValue(parts, `${key}[${index}]`, item);
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
if (typeof value === "object") {
|
|
1432
|
-
for (const [field, item] of Object.entries(value)) appendQueryValue(parts, `${key}[${field}]`, item);
|
|
1433
|
-
return;
|
|
1434
|
-
}
|
|
1435
|
-
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
1436
|
-
};
|
|
1437
|
-
/**
|
|
1438
|
-
* Serialises a query object the way the API parses it (qs bracket notation), for example
|
|
1439
|
-
* `ordering[0][field]=createdAt&ordering[0][direction]=desc`. Every key and value is
|
|
1440
|
-
* percent-encoded and missing values are omitted.
|
|
1441
|
-
*/
|
|
1442
|
-
const stringifyQuery = (query) => {
|
|
1443
|
-
const parts = [];
|
|
1444
|
-
for (const [key, value] of Object.entries(query)) appendQueryValue(parts, key, value);
|
|
1445
|
-
return parts.join("&");
|
|
1446
|
-
};
|
|
1447
|
-
/**
|
|
1448
|
-
* Whether an asset has a moderation decision (`classification.moderation.status` is no longer
|
|
1449
|
-
* `pending`) or failed processing; `assets.waitForDecision` returns at the first such state.
|
|
1450
|
-
*/
|
|
1451
|
-
const isAssetDecided = (asset) => asset.classification.moderation.status !== "pending" || asset.classification.status === "failed";
|
|
1726
|
+
const isAssetDecided = (asset) => asset.classification.status === "completed" || asset.classification.status === "failed";
|
|
1452
1727
|
const DECISION_POLL_DELAY_FACTOR = 1.5;
|
|
1453
1728
|
const DECISION_POLL_MAX_DELAY_MS = 2e3;
|
|
1454
1729
|
const DEFAULT_DECISION_TIMEOUT_MS = 6e4;
|
|
1455
1730
|
/**
|
|
1456
|
-
* Retrieves an asset until it
|
|
1731
|
+
* Retrieves an asset until it is settled (see `isAssetDecided`), waiting 0.5s between checks and
|
|
1732
|
+
* 1.5 times longer
|
|
1457
1733
|
* each time, up to 2s. Rejects with `sdk/timeout` once `timeoutMs` passes without one.
|
|
1458
1734
|
*/
|
|
1459
1735
|
const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_MS, signal }, sleep, now = Date.now) => {
|
|
@@ -1477,24 +1753,177 @@ const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_
|
|
|
1477
1753
|
delay = Math.min(DECISION_POLL_MAX_DELAY_MS, delay * DECISION_POLL_DELAY_FACTOR);
|
|
1478
1754
|
}
|
|
1479
1755
|
};
|
|
1480
|
-
// src/client/
|
|
1481
|
-
/**
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
if (
|
|
1490
|
-
|
|
1756
|
+
// src/client/CalmLensViewerClaims.ts
|
|
1757
|
+
/** The ISO 3166-1 alpha-2 countries a viewer's `region` can be. EU is not a viewer country. */
|
|
1758
|
+
const VIEWER_COUNTRIES = new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
|
|
1759
|
+
new Set("AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE".split(" "));
|
|
1760
|
+
/**
|
|
1761
|
+
* The claims to send, with `region` and `ageConfirmed` in that order, or `undefined` when the
|
|
1762
|
+
* value isn't an object of only a viewer country `region` and a boolean `ageConfirmed`.
|
|
1763
|
+
*/
|
|
1764
|
+
const parseViewerClaims = (value) => {
|
|
1765
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
1766
|
+
const { region, ageConfirmed, ...rest } = value;
|
|
1767
|
+
if (Object.keys(rest).length) return void 0;
|
|
1768
|
+
if (region !== void 0 && (typeof region !== "string" || !VIEWER_COUNTRIES.has(region))) return void 0;
|
|
1769
|
+
if (ageConfirmed !== void 0 && typeof ageConfirmed !== "boolean") return void 0;
|
|
1770
|
+
return {
|
|
1771
|
+
...region !== void 0 && { region },
|
|
1772
|
+
...ageConfirmed !== void 0 && { ageConfirmed }
|
|
1773
|
+
};
|
|
1774
|
+
};
|
|
1775
|
+
// src/client/CalmLensCdn.ts
|
|
1776
|
+
const ASSET_RESOURCE_PATHS = {
|
|
1777
|
+
original: "original",
|
|
1778
|
+
rendered: "rendered",
|
|
1779
|
+
preview: "preview",
|
|
1780
|
+
placeholder: "placeholder",
|
|
1781
|
+
hls: "hls/index.m3u8",
|
|
1782
|
+
embed: "embed",
|
|
1783
|
+
info: "info"
|
|
1784
|
+
};
|
|
1785
|
+
/** The prefix of an asset URL segment that names the asset by its external ID. */
|
|
1786
|
+
const EXTERNAL_ID_SEGMENT_PREFIX = "ext:";
|
|
1787
|
+
/** Every CDN resource beneath an asset URL, as `getAssetUrl` and `signAssetUrl` accept them. */
|
|
1788
|
+
const CDN_RESOURCES = Object.keys(ASSET_RESOURCE_PATHS);
|
|
1789
|
+
const UNSELECTABLE = /* @__PURE__ */ new Set([
|
|
1790
|
+
"original",
|
|
1791
|
+
"hls",
|
|
1792
|
+
"embed",
|
|
1793
|
+
"placeholder",
|
|
1794
|
+
"info"
|
|
1795
|
+
]);
|
|
1796
|
+
/** The longest signed URL lifetime the API accepts: 24 hours. */
|
|
1797
|
+
const MAX_SIGNED_URL_EXPIRES_IN = 86400;
|
|
1798
|
+
/**
|
|
1799
|
+
* The asset segment of a CDN URL: the asset ID, or `ext:` and the URL-encoded external ID. Exactly
|
|
1800
|
+
* one of them must be given.
|
|
1801
|
+
*/
|
|
1802
|
+
const getAssetSegment = (options) => {
|
|
1803
|
+
const { assetId, externalId } = options;
|
|
1804
|
+
if (assetId === void 0 === (externalId === void 0)) throw invalidArgument("Pass either assetId or externalId");
|
|
1805
|
+
if (assetId !== void 0) return encodePathSegment(assetId, "Asset ID");
|
|
1806
|
+
if (typeof externalId !== "string" || !externalId) throw invalidArgument("External ID is required");
|
|
1807
|
+
return `${EXTERNAL_ID_SEGMENT_PREFIX}${encodeURIComponent(externalId)}`;
|
|
1808
|
+
};
|
|
1809
|
+
/**
|
|
1810
|
+
* The viewer claims a URL carries: the region, and `ageConfirmed` only when true. Unconfirmed age
|
|
1811
|
+
* and no region are the CDN's defaults, left out so default URLs stay cacheable.
|
|
1812
|
+
*/
|
|
1813
|
+
const toUrlViewerClaims = (claims) => {
|
|
1814
|
+
if (claims === void 0) return void 0;
|
|
1815
|
+
const parsed = parseViewerClaims(claims);
|
|
1816
|
+
if (!parsed) throw invalidArgument("Invalid viewerClaims");
|
|
1817
|
+
const { region, ageConfirmed } = parsed;
|
|
1818
|
+
if (!region && ageConfirmed !== true) return void 0;
|
|
1819
|
+
return {
|
|
1820
|
+
...region ? { region } : {},
|
|
1821
|
+
...ageConfirmed === true ? { ageConfirmed } : {}
|
|
1822
|
+
};
|
|
1823
|
+
};
|
|
1824
|
+
/** The `?viewerClaims=` query of a URL with these claims, or an empty string for the defaults. */
|
|
1825
|
+
const viewerClaimsQuery = (claims) => {
|
|
1826
|
+
const sent = toUrlViewerClaims(claims);
|
|
1827
|
+
return sent ? `?${new URLSearchParams({ viewerClaims: JSON.stringify(sent) })}` : "";
|
|
1828
|
+
};
|
|
1829
|
+
/**
|
|
1830
|
+
* Appends a resource, its `@lens` and transform selector, and the viewer claims to an asset URL
|
|
1831
|
+
* (public or signed). Without `resource` the URL stays the asset URL, which takes no selector.
|
|
1832
|
+
*/
|
|
1833
|
+
const appendAssetLocation = (assetUrl, location) => {
|
|
1834
|
+
const { resource, lens, transform, viewerClaims } = location;
|
|
1835
|
+
const selected = lens !== void 0 || transform !== void 0;
|
|
1836
|
+
let path = assetUrl;
|
|
1837
|
+
if (resource === void 0) {
|
|
1838
|
+
if (selected) throw invalidArgument("A lens or transform needs a resource, such as rendered");
|
|
1839
|
+
} else {
|
|
1840
|
+
if (typeof resource !== "string" || !Object.hasOwn(ASSET_RESOURCE_PATHS, resource)) throw invalidArgument(`resource must be one of ${CDN_RESOURCES.join(", ")}`);
|
|
1841
|
+
if (UNSELECTABLE.has(resource) && selected) throw invalidArgument(`The ${resource} resource takes no lens or transform`);
|
|
1842
|
+
path = `${assetUrl}/${ASSET_RESOURCE_PATHS[resource]}`;
|
|
1843
|
+
const selector = transformSelector(transform);
|
|
1844
|
+
const parts = [...lens !== void 0 ? [`@${encodePathSegment(lens, "Lens")}`] : [], ...selector ? [typeof transform === "string" ? encodeURI(selector) : selector] : []];
|
|
1845
|
+
if (parts.length) path = `${path}/${parts.join(",")}`;
|
|
1846
|
+
}
|
|
1847
|
+
return `${path}${viewerClaimsQuery(viewerClaims)}`;
|
|
1848
|
+
};
|
|
1849
|
+
/** An asset's public URL beneath a CDN base URL, with any resource, selector and claims. */
|
|
1850
|
+
const buildAssetUrl = (cdnBaseUrl, projectId, options) => {
|
|
1851
|
+
const { assetId, externalId, resource, lens, transform, viewerClaims } = options;
|
|
1852
|
+
const base = `${cdnBaseUrl.replace(/\/+$/, "")}/assets/${encodePathSegment(projectId, "Project ID")}/${getAssetSegment({
|
|
1853
|
+
assetId,
|
|
1854
|
+
externalId
|
|
1855
|
+
})}`;
|
|
1856
|
+
return appendAssetLocation(base, {
|
|
1857
|
+
resource,
|
|
1858
|
+
lens,
|
|
1859
|
+
transform,
|
|
1860
|
+
viewerClaims
|
|
1861
|
+
});
|
|
1862
|
+
};
|
|
1863
|
+
/** Checks `signAssetUrl`'s own options as the API does, before anything is sent. */
|
|
1864
|
+
const validateSignAssetUrlOptions = (options) => {
|
|
1865
|
+
const { expiresIn, original } = options;
|
|
1866
|
+
if (expiresIn !== void 0 && (!Number.isInteger(expiresIn) || expiresIn < 1 || expiresIn > 86400)) throw invalidArgument(`expiresIn must be a whole number from 1 to ${MAX_SIGNED_URL_EXPIRES_IN}`);
|
|
1867
|
+
if (original !== void 0 && typeof original !== "boolean") throw invalidArgument("original must be a boolean");
|
|
1868
|
+
getAssetSegment(options);
|
|
1869
|
+
appendAssetLocation("", options);
|
|
1870
|
+
};
|
|
1871
|
+
/** An asset URL without its query: the viewer claims it carried, if any, are returned apart. */
|
|
1872
|
+
const splitAssetUrl = (url) => {
|
|
1873
|
+
const [path = "", query] = url.split("?", 2);
|
|
1874
|
+
const base = path.replace(/\/+$/, "");
|
|
1875
|
+
const raw = query ? new URLSearchParams(query).get("viewerClaims") : null;
|
|
1876
|
+
if (raw === null) return { base };
|
|
1877
|
+
try {
|
|
1878
|
+
return {
|
|
1879
|
+
base,
|
|
1880
|
+
claims: JSON.parse(raw)
|
|
1881
|
+
};
|
|
1882
|
+
} catch {
|
|
1883
|
+
throw invalidArgument("The asset URL's viewerClaims are not JSON");
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
const isAssetInfo = (value) => {
|
|
1887
|
+
if (!value || typeof value !== "object") return false;
|
|
1888
|
+
const info = value;
|
|
1889
|
+
return typeof info.id === "string" && typeof info.projectId === "string" && typeof info.type === "string" && !!info.content && typeof info.content === "object" && (info.availability === "available" || info.availability === "age-restricted" || info.availability === "unavailable");
|
|
1890
|
+
};
|
|
1891
|
+
/**
|
|
1892
|
+
* The display info of an asset URL (public or signed): `{url}/info`, an allowlist of the asset's
|
|
1893
|
+
* public fields and whether this viewer can see it now (`availability`). Viewer claims come from
|
|
1894
|
+
* `viewerClaims`, else from the URL. A refusal throws `CalmLensError` with the CDN's code, such as
|
|
1895
|
+
* `signed-url/expired` or `asset/not-found`.
|
|
1896
|
+
*/
|
|
1897
|
+
const getAssetInfo = async (url, options = {}) => {
|
|
1898
|
+
if (typeof url !== "string" || !URL.canParse(url)) throw invalidArgument("url must be an absolute asset URL");
|
|
1899
|
+
const { base, claims } = splitAssetUrl(url);
|
|
1900
|
+
const infoUrl = `${base}/info${viewerClaimsQuery(options.viewerClaims ?? claims)}`;
|
|
1901
|
+
const fetcher = options.fetch ?? globalThis.fetch;
|
|
1902
|
+
let response;
|
|
1903
|
+
try {
|
|
1904
|
+
response = await fetcher(infoUrl, {
|
|
1905
|
+
headers: { Accept: "application/json" },
|
|
1906
|
+
signal: options.signal
|
|
1907
|
+
});
|
|
1908
|
+
} catch (cause) {
|
|
1909
|
+
if (options.signal?.aborted) throw cause;
|
|
1910
|
+
throw new CalmLensError(SDK_ERROR_CODES.TRANSPORT_ERROR, {
|
|
1911
|
+
message: "The asset's info could not be fetched",
|
|
1912
|
+
cause
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
1916
|
+
if (!response.ok) throw toHttpError(response, bytes);
|
|
1917
|
+
let data;
|
|
1918
|
+
try {
|
|
1919
|
+
data = JSON.parse(new TextDecoder().decode(bytes));
|
|
1920
|
+
} catch {}
|
|
1921
|
+
if (!isAssetInfo(data)) throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
1922
|
+
message: "The CDN returned no asset info",
|
|
1923
|
+
status: response.status
|
|
1924
|
+
});
|
|
1925
|
+
return data;
|
|
1491
1926
|
};
|
|
1492
|
-
/** The `User-Agent` the SDK sends from server runtimes, e.g. `calmlens-js/0.10.0 (node/22.12.0)`. */
|
|
1493
|
-
const getUserAgent = () => `calmlens-js/${SDK_VERSION} (${runtimeName()})`;
|
|
1494
|
-
/** True in a web page, where API keys would be visible to every visitor. */
|
|
1495
|
-
const isBrowserRuntime = () => typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
1496
|
-
/** True in a React Native app, where an API key ships inside the app for anyone to extract. */
|
|
1497
|
-
const isReactNativeRuntime = () => globalThis.navigator?.product === "ReactNative";
|
|
1498
1927
|
// src/contract/ModerationContextLimits-BIMUlk2e.js
|
|
1499
1928
|
/** The most recent earlier posts CalmLens uses. */
|
|
1500
1929
|
const MODERATION_CONTEXT_USED_ITEMS = 5;
|
|
@@ -1527,4 +1956,4 @@ const selectModerationContextItems = (items) => {
|
|
|
1527
1956
|
}
|
|
1528
1957
|
return selected;
|
|
1529
1958
|
};
|
|
1530
|
-
export {
|
|
1959
|
+
export { getRejectedUploadMimeTypeError as A, invalidArgument as B, validateBatchAssetsOptions as C, MAX_DIRECT_IMAGE_UPLOAD_BYTES as D, DOMAIN as E, isBrowserRuntime as F, API_ERROR_CODES as H, isReactNativeRuntime as I, CALMLENS_ERROR_CODES as L, CalmLensTransport as M, sleep as N, MAX_IMAGE_UPLOAD_BYTES as O, SDK_VERSION as P, CalmLensError as R, validateAppClientOptions as S, validateServerClientOptions as T, API_ERROR_DEFINITIONS as U, invalidConfig as V, randomUuid as _, appendAssetLocation as a, toTextAssetOptions as b, toUrlViewerClaims as c, checkOptionKeys as d, checkTransformOptions as f, pollForDecision as g, parseTransformSelector as h, CDN_RESOURCES as i, normalizeUploadMimeType as j, MAX_NON_IMAGE_UPLOAD_BYTES as k, validateSignAssetUrlOptions as l, isAcceptedUploadMimeType as m, MODERATION_CONTEXT_USED_ITEMS as n, buildAssetUrl as o, encodePathSegment as p, selectModerationContextItems as r, getAssetInfo as s, MODERATION_CONTEXT_USED_CHARACTERS as t, DEFAULT_CDN_BASE_URL as u, serializeTransform as v, validateRequestOptions as w, transformSelector as x, stringifyQuery as y, SDK_ERROR_CODES as z };
|