calmlens 0.25.0 → 0.26.1
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 +14 -14
- package/bin/calmlens.js +2202 -521
- package/cjs/{BrowserUpload-AO2-2U5Z.js → BrowserUpload-DdkcoZLH.js} +1 -1
- package/{esm/BrowserUpload-D2lemMIU.d.ts → cjs/BrowserUpload-zYWKtFSs.d.ts} +2 -2
- package/cjs/{CalmLensAppClient-nv6qwja0.js → CalmLensAppClient-Gu9mU_66.js} +22 -15
- package/{esm/CalmLensAppClient-Dt0t9Bk6.d.ts → cjs/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
- package/cjs/{CalmLensOptionKeys-BvCac9NO.js → CalmLensOptionKeys-BCITGsr9.js} +138 -90
- package/cjs/CalmLensServerClient-D5-njsNk.d.ts +357 -0
- package/cjs/{CalmLensServerClient-B60kCBCR.js → CalmLensServerClient-DHmAPT1u.js} +283 -303
- package/cjs/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +127 -59
- package/cjs/{Core-DSMxC2GL.d.ts → Core-CREGGR0L.d.ts} +10 -3
- package/cjs/{Core-Cw4IxFUq.js → Core-DAf9lqe2.js} +30 -12
- package/{esm/ModerationContextLimits-Bqr0duav.js → cjs/ModerationContextLimits-D4iwqoN_.js} +858 -28
- package/cjs/{ReactUpload--oDFltw2.js → ReactUpload-BNIbpxIH.js} +38 -2
- package/cjs/ReactUpload-D4htIz8X.d.ts +27 -0
- package/cjs/{UploadController-ObdgTaBl.js → UploadController-B_lKxvpM.js} +16 -3
- package/cjs/{WebhookPayload-DLGGOGW6.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
- package/cjs/app.d.ts +5 -5
- package/cjs/app.js +20 -2
- package/cjs/elements.d.ts +5 -5
- package/cjs/elements.js +102 -67
- package/cjs/{index-AAWuerkU.d.ts → index-CtpQldn_.d.ts} +2 -2
- package/cjs/index.d.ts +4 -4
- package/cjs/index.js +19 -1
- package/cjs/react-native.d.ts +3 -3
- package/cjs/react-native.js +6 -4
- package/cjs/react.d.ts +5 -4
- package/cjs/react.js +10 -14
- package/cjs/server.d.ts +5 -5
- package/cjs/server.js +20 -2
- package/cjs/testing.d.ts +11 -9
- package/cjs/testing.js +72 -41
- package/cjs/{ui-CcuGKTcL.d.ts → ui-BwFPFrno.d.ts} +2 -2
- package/cjs/{ui-CA16jyfZ.js → ui-CvlJmRYM.js} +6 -4
- package/cjs/ui.d.ts +3 -3
- package/cjs/ui.js +4 -3
- package/cjs/vue.d.ts +15 -8
- package/cjs/vue.js +29 -16
- package/esm/{BrowserUpload-Co4T6uGk.js → BrowserUpload-BAWYEBd7.js} +1 -1
- package/{cjs/BrowserUpload-D2lemMIU.d.ts → esm/BrowserUpload-zYWKtFSs.d.ts} +2 -2
- package/esm/{CalmLensAppClient-BRzy4dwn.js → CalmLensAppClient-DNkIZb6x.js} +22 -15
- package/{cjs/CalmLensAppClient-Dt0t9Bk6.d.ts → esm/CalmLensAppClient-mTTjqpRc.d.ts} +5 -11
- package/esm/{CalmLensOptionKeys-bE3rb5PN.js → CalmLensOptionKeys-CYHJo3nV.js} +133 -91
- package/esm/{CalmLensServerClient-_PRi90wI.js → CalmLensServerClient-B1AiR4nv.js} +283 -303
- package/esm/CalmLensServerClient-D5-njsNk.d.ts +357 -0
- package/esm/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-Df8eBgWB.d.ts} +127 -59
- package/esm/{Core-DSMxC2GL.d.ts → Core-CREGGR0L.d.ts} +10 -3
- package/esm/{Core-CtbYmeXG.js → Core-xNBQxZWH.js} +30 -12
- package/{cjs/ModerationContextLimits-Cn9RvnZH.js → esm/ModerationContextLimits-DxuPP4uM.js} +475 -285
- package/esm/{ReactUpload-B5itHBSF.js → ReactUpload-BWifQdLv.js} +34 -4
- package/esm/ReactUpload-D4htIz8X.d.ts +27 -0
- package/esm/{UploadController-C7fL3Iz9.js → UploadController-jlJdddyI.js} +11 -4
- package/esm/{WebhookPayload-DLGGOGW6.d.ts → WebhookPayload-DMa6ihHr.d.ts} +152 -3
- package/esm/app.d.ts +5 -5
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +5 -5
- package/esm/elements.js +102 -68
- package/esm/{index-AAWuerkU.d.ts → index-CtpQldn_.d.ts} +2 -2
- package/esm/index.d.ts +4 -4
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +3 -3
- package/esm/react-native.js +5 -5
- package/esm/react.d.ts +5 -4
- package/esm/react.js +9 -15
- package/esm/server.d.ts +5 -5
- package/esm/server.js +3 -3
- package/esm/styles.css +28 -10
- package/esm/svelte/CalmLensUploader.svelte +17 -17
- package/esm/svelte/context.js +21 -0
- package/esm/svelte/index.d.ts +12 -0
- package/esm/svelte/index.js +1 -0
- package/esm/testing.d.ts +11 -9
- package/esm/testing.js +72 -41
- package/esm/{ui-B98AucZA.js → ui-BXzzqh7M.js} +6 -4
- package/esm/{ui-CcuGKTcL.d.ts → ui-BwFPFrno.d.ts} +2 -2
- package/esm/ui.d.ts +3 -3
- package/esm/ui.js +4 -4
- package/esm/vue.d.ts +15 -8
- package/esm/vue.js +29 -18
- package/package.json +16 -6
- package/cjs/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
- package/cjs/ReactUpload-CW4NzAsh.d.ts +0 -17
- package/esm/CalmLensServerClient-7XjQaeKu.d.ts +0 -353
- package/esm/ReactUpload-CW4NzAsh.d.ts +0 -17
|
@@ -636,6 +636,69 @@ const CALMLENS_ERROR_CODES = {
|
|
|
636
636
|
...API_ERROR_CODES,
|
|
637
637
|
...SDK_ERROR_CODES
|
|
638
638
|
};
|
|
639
|
+
const KIND_PARENTS = {
|
|
640
|
+
error: null,
|
|
641
|
+
api: "error",
|
|
642
|
+
"bad-request": "api",
|
|
643
|
+
authentication: "api",
|
|
644
|
+
"permission-denied": "api",
|
|
645
|
+
"not-found": "api",
|
|
646
|
+
conflict: "api",
|
|
647
|
+
"payload-too-large": "api",
|
|
648
|
+
"unprocessable-entity": "api",
|
|
649
|
+
"rate-limit": "api",
|
|
650
|
+
server: "api",
|
|
651
|
+
connection: "error",
|
|
652
|
+
timeout: "error",
|
|
653
|
+
cancelled: "error",
|
|
654
|
+
"invalid-argument": "error",
|
|
655
|
+
configuration: "invalid-argument",
|
|
656
|
+
"invalid-response": "error",
|
|
657
|
+
"webhook-verification": "error"
|
|
658
|
+
};
|
|
659
|
+
const STATUS_KINDS = {
|
|
660
|
+
400: "bad-request",
|
|
661
|
+
401: "authentication",
|
|
662
|
+
403: "permission-denied",
|
|
663
|
+
404: "not-found",
|
|
664
|
+
409: "conflict",
|
|
665
|
+
413: "payload-too-large",
|
|
666
|
+
422: "unprocessable-entity",
|
|
667
|
+
429: "rate-limit"
|
|
668
|
+
};
|
|
669
|
+
/** The kinds of the SDK's own codes, whatever the status. */
|
|
670
|
+
const CODE_KINDS = {
|
|
671
|
+
"sdk/transport-error": "connection",
|
|
672
|
+
"sdk/timeout": "timeout",
|
|
673
|
+
"sdk/cancelled": "cancelled",
|
|
674
|
+
"sdk/invalid-response": "invalid-response",
|
|
675
|
+
"sdk/response-too-large": "invalid-response",
|
|
676
|
+
"sdk/invalid-argument": "invalid-argument",
|
|
677
|
+
"sdk/invalid-config": "configuration",
|
|
678
|
+
"sdk/no-fetch": "configuration",
|
|
679
|
+
"sdk/invalid-webhook-signature": "webhook-verification",
|
|
680
|
+
"sdk/invalid-webhook-payload": "webhook-verification"
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* The kind of an error with `code` and `status`: the SDK's own codes by code; any other error by
|
|
684
|
+
* its HTTP status when the API answered (`api` for a status without a kind of its own, or a
|
|
685
|
+
* hidden one); and an error the SDK raised before sending, such as `upload/unsupported-type`, as
|
|
686
|
+
* `invalid-argument`.
|
|
687
|
+
*/
|
|
688
|
+
const errorKindOf = (code, status) => {
|
|
689
|
+
const byCode = CODE_KINDS[code];
|
|
690
|
+
if (byCode) return byCode;
|
|
691
|
+
if (status === void 0) return code === "sdk/http-error" ? "api" : "invalid-argument";
|
|
692
|
+
if (status >= 500) return "server";
|
|
693
|
+
return STATUS_KINDS[status] ?? "api";
|
|
694
|
+
};
|
|
695
|
+
/** Whether `kind` is `ancestor` or one of its descendants. */
|
|
696
|
+
const isErrorKind = (kind, ancestor) => {
|
|
697
|
+
for (let current = kind; current; current = KIND_PARENTS[current]) if (current === ancestor) return true;
|
|
698
|
+
return false;
|
|
699
|
+
};
|
|
700
|
+
/** The longest API error body an error keeps. */
|
|
701
|
+
const MAX_ERROR_BODY_LENGTH = 4096;
|
|
639
702
|
const BRAND = Symbol.for("calmlens.sdk.CalmLensError");
|
|
640
703
|
const RETRYABLE_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
641
704
|
429,
|
|
@@ -658,11 +721,21 @@ const RETRYABLE_CODES = /* @__PURE__ */ new Set([
|
|
|
658
721
|
* from any copy of the SDK, so they work when ESM and CommonJS builds are loaded side by side.
|
|
659
722
|
*/
|
|
660
723
|
var CalmLensError = class CalmLensError extends Error {
|
|
724
|
+
static {
|
|
725
|
+
this.kind = "error";
|
|
726
|
+
}
|
|
661
727
|
constructor(code, options = {}) {
|
|
662
728
|
const id = typeof code === "string" ? code : code.id;
|
|
663
729
|
const defaultMessage = typeof code === "string" ? void 0 : code.defaultMessage;
|
|
664
730
|
super(`[calmlens] ${options.message ?? defaultMessage ?? id}`, { cause: options.cause });
|
|
665
|
-
|
|
731
|
+
const kind = errorKindOf(id, options.status);
|
|
732
|
+
if (new.target === CalmLensError) {
|
|
733
|
+
const KindClass = ERROR_CLASSES[kind];
|
|
734
|
+
if (KindClass !== CalmLensError) return new KindClass(code, options);
|
|
735
|
+
}
|
|
736
|
+
this.name = new.target.name;
|
|
737
|
+
this.kind = kind;
|
|
738
|
+
this.body = options.body?.slice(0, MAX_ERROR_BODY_LENGTH);
|
|
666
739
|
this.code = id;
|
|
667
740
|
this.status = options.status;
|
|
668
741
|
this.details = options.details;
|
|
@@ -675,8 +748,20 @@ var CalmLensError = class CalmLensError extends Error {
|
|
|
675
748
|
static isCalmLensError(value) {
|
|
676
749
|
return typeof value === "object" && value !== null && value[BRAND] === true;
|
|
677
750
|
}
|
|
751
|
+
/**
|
|
752
|
+
* `error instanceof CalmLensNotFoundError` (or any kind's class) is true for errors of that kind
|
|
753
|
+
* and its descendants, from any copy of the SDK.
|
|
754
|
+
*/
|
|
678
755
|
static [Symbol.hasInstance](value) {
|
|
679
|
-
|
|
756
|
+
if (!CalmLensError.isCalmLensError(value)) return false;
|
|
757
|
+
const expected = this.kind;
|
|
758
|
+
if (expected === "error") return true;
|
|
759
|
+
const { kind } = value;
|
|
760
|
+
return kind in KIND_PARENTS && isErrorKind(kind, expected);
|
|
761
|
+
}
|
|
762
|
+
/** Whether this error is of `kind` or a kind beneath it, such as `api` for a `not-found` error. */
|
|
763
|
+
isKind(kind) {
|
|
764
|
+
return isErrorKind(this.kind, kind);
|
|
680
765
|
}
|
|
681
766
|
/**
|
|
682
767
|
* Whether the SDK raised this error itself, with no HTTP response: before sending (an invalid
|
|
@@ -706,9 +791,283 @@ const invalidArgument = (message, details) => new CalmLensError(SDK_ERROR_CODES.
|
|
|
706
791
|
details
|
|
707
792
|
});
|
|
708
793
|
const invalidConfig = (message) => new CalmLensError(SDK_ERROR_CODES.INVALID_CONFIG, { message });
|
|
794
|
+
/** The API, or a proxy in front of it, answered with a non-2xx status. */
|
|
795
|
+
var CalmLensApiError = class extends CalmLensError {
|
|
796
|
+
static {
|
|
797
|
+
this.kind = "api";
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
/** HTTP 400: the request was invalid. */
|
|
801
|
+
var CalmLensBadRequestError = class extends CalmLensApiError {
|
|
802
|
+
static {
|
|
803
|
+
this.kind = "bad-request";
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
/** HTTP 401: the API key is missing or invalid. */
|
|
807
|
+
var CalmLensAuthenticationError = class extends CalmLensApiError {
|
|
808
|
+
static {
|
|
809
|
+
this.kind = "authentication";
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
/** HTTP 403: the API key lacks a grant, or the viewer can't see the asset. */
|
|
813
|
+
var CalmLensPermissionDeniedError = class extends CalmLensApiError {
|
|
814
|
+
static {
|
|
815
|
+
this.kind = "permission-denied";
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
/** HTTP 404: the resource doesn't exist or isn't visible to the API key. */
|
|
819
|
+
var CalmLensNotFoundError = class extends CalmLensApiError {
|
|
820
|
+
static {
|
|
821
|
+
this.kind = "not-found";
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
/** HTTP 409: the request conflicts with the resource's state, such as a changed revision. */
|
|
825
|
+
var CalmLensConflictError = class extends CalmLensApiError {
|
|
826
|
+
static {
|
|
827
|
+
this.kind = "conflict";
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
/** HTTP 413: the content is over a size limit. */
|
|
831
|
+
var CalmLensPayloadTooLargeError = class extends CalmLensApiError {
|
|
832
|
+
static {
|
|
833
|
+
this.kind = "payload-too-large";
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
/** HTTP 422: the content can't be processed. */
|
|
837
|
+
var CalmLensUnprocessableEntityError = class extends CalmLensApiError {
|
|
838
|
+
static {
|
|
839
|
+
this.kind = "unprocessable-entity";
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
/** HTTP 429: too many requests; `retryAfter` says how long to wait. */
|
|
843
|
+
var CalmLensRateLimitError = class extends CalmLensApiError {
|
|
844
|
+
static {
|
|
845
|
+
this.kind = "rate-limit";
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
/** HTTP 500 or above: the API failed. */
|
|
849
|
+
var CalmLensServerError = class extends CalmLensApiError {
|
|
850
|
+
static {
|
|
851
|
+
this.kind = "server";
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
/** No complete response: the connection failed or was cut (`sdk/transport-error`). */
|
|
855
|
+
var CalmLensConnectionError = class extends CalmLensError {
|
|
856
|
+
static {
|
|
857
|
+
this.kind = "connection";
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
/** A request took longer than its timeout, or a wait reached its deadline (`sdk/timeout`). */
|
|
861
|
+
var CalmLensTimeoutError = class extends CalmLensError {
|
|
862
|
+
static {
|
|
863
|
+
this.kind = "timeout";
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
/** The caller cancelled the call through a signal (`sdk/cancelled`). */
|
|
867
|
+
var CalmLensCancelledError = class extends CalmLensError {
|
|
868
|
+
static {
|
|
869
|
+
this.kind = "cancelled";
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
/** The SDK refused the call before sending anything. */
|
|
873
|
+
var CalmLensInvalidArgumentError = class extends CalmLensError {
|
|
874
|
+
static {
|
|
875
|
+
this.kind = "invalid-argument";
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
/** The client's configuration is invalid (`sdk/invalid-config`, `sdk/no-fetch`). */
|
|
879
|
+
var CalmLensConfigurationError = class extends CalmLensInvalidArgumentError {
|
|
880
|
+
static {
|
|
881
|
+
this.kind = "configuration";
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
/** A response wasn't what the operation returns (`sdk/invalid-response`, `sdk/response-too-large`). */
|
|
885
|
+
var CalmLensInvalidResponseError = class extends CalmLensError {
|
|
886
|
+
static {
|
|
887
|
+
this.kind = "invalid-response";
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
/** A webhook delivery couldn't be verified or parsed. */
|
|
891
|
+
var CalmLensWebhookVerificationError = class extends CalmLensError {
|
|
892
|
+
static {
|
|
893
|
+
this.kind = "webhook-verification";
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
/** Each kind's class. */
|
|
897
|
+
const ERROR_CLASSES = {
|
|
898
|
+
error: CalmLensError,
|
|
899
|
+
api: CalmLensApiError,
|
|
900
|
+
"bad-request": CalmLensBadRequestError,
|
|
901
|
+
authentication: CalmLensAuthenticationError,
|
|
902
|
+
"permission-denied": CalmLensPermissionDeniedError,
|
|
903
|
+
"not-found": CalmLensNotFoundError,
|
|
904
|
+
conflict: CalmLensConflictError,
|
|
905
|
+
"payload-too-large": CalmLensPayloadTooLargeError,
|
|
906
|
+
"unprocessable-entity": CalmLensUnprocessableEntityError,
|
|
907
|
+
"rate-limit": CalmLensRateLimitError,
|
|
908
|
+
server: CalmLensServerError,
|
|
909
|
+
connection: CalmLensConnectionError,
|
|
910
|
+
timeout: CalmLensTimeoutError,
|
|
911
|
+
cancelled: CalmLensCancelledError,
|
|
912
|
+
"invalid-argument": CalmLensInvalidArgumentError,
|
|
913
|
+
configuration: CalmLensConfigurationError,
|
|
914
|
+
"invalid-response": CalmLensInvalidResponseError,
|
|
915
|
+
"webhook-verification": CalmLensWebhookVerificationError
|
|
916
|
+
};
|
|
917
|
+
// src/client/CalmLensLogging.ts
|
|
918
|
+
const LOG_LEVELS = [
|
|
919
|
+
"off",
|
|
920
|
+
"info",
|
|
921
|
+
"debug"
|
|
922
|
+
];
|
|
923
|
+
/**
|
|
924
|
+
* An environment variable, in runtimes that have an environment: Node.js, Bun and Deno (with
|
|
925
|
+
* `--allow-env`). Cloudflare Workers and browsers have none, so it is `undefined` there.
|
|
926
|
+
*/
|
|
927
|
+
const readEnv = (name) => {
|
|
928
|
+
const runtime = globalThis;
|
|
929
|
+
try {
|
|
930
|
+
const value = runtime.process?.env?.[name] ?? runtime.Deno?.env?.get(name);
|
|
931
|
+
return value === void 0 || value.trim() === "" ? void 0 : value.trim();
|
|
932
|
+
} catch {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
/** The log level: the option, else `CALMLENS_LOG` from the environment, else `off`. */
|
|
937
|
+
const resolveLogLevel = (option, fromEnv) => {
|
|
938
|
+
if (option !== void 0) {
|
|
939
|
+
if (!LOG_LEVELS.includes(option)) throw invalidConfig(`logLevel must be one of ${LOG_LEVELS.join(", ")}`);
|
|
940
|
+
return option;
|
|
941
|
+
}
|
|
942
|
+
const env = fromEnv ? readEnv("CALMLENS_LOG")?.toLowerCase() : void 0;
|
|
943
|
+
return LOG_LEVELS.includes(env) ? env : "off";
|
|
944
|
+
};
|
|
945
|
+
/**
|
|
946
|
+
* One line about an attempt: what was sent where, how it ended and what happens next. It holds no
|
|
947
|
+
* API key, upload token, query (which can hold viewer claims), signed URL or body.
|
|
948
|
+
*/
|
|
949
|
+
const describeAttempt = (attempt) => {
|
|
950
|
+
const outcome = attempt.status !== null ? `HTTP ${attempt.status}` : attempt.errorCode !== null ? attempt.errorCode : "no response";
|
|
951
|
+
const parts = [
|
|
952
|
+
`[calmlens] ${attempt.operation ?? "request"} ${attempt.method} ${attempt.path}`,
|
|
953
|
+
`attempt ${attempt.attempt}`,
|
|
954
|
+
outcome,
|
|
955
|
+
`${attempt.durationMs}ms`
|
|
956
|
+
];
|
|
957
|
+
if (attempt.requestId) parts.push(`request ${attempt.requestId}`);
|
|
958
|
+
if (attempt.delayMs !== null) parts.push(`retrying in ${attempt.delayMs}ms`);
|
|
959
|
+
return parts.join(" · ");
|
|
960
|
+
};
|
|
961
|
+
// src/client/CalmLensPagination.ts
|
|
962
|
+
/** Attaches `lastResponse` to a parsed JSON result; other values are returned unchanged. */
|
|
963
|
+
const withLastResponse = (value, lastResponse) => {
|
|
964
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) Object.defineProperty(value, "lastResponse", {
|
|
965
|
+
value: lastResponse,
|
|
966
|
+
enumerable: false,
|
|
967
|
+
writable: false,
|
|
968
|
+
configurable: true
|
|
969
|
+
});
|
|
970
|
+
return value;
|
|
971
|
+
};
|
|
972
|
+
/** `value` with `from`'s `lastResponse`, for results the SDK builds from a response. */
|
|
973
|
+
const copyLastResponse = (value, from) => {
|
|
974
|
+
const lastResponse = from?.lastResponse;
|
|
975
|
+
return lastResponse ? withLastResponse(value, lastResponse) : value;
|
|
976
|
+
};
|
|
977
|
+
/** The most items `autoPagingToArray` collects; iterate with `for await` for more. */
|
|
978
|
+
const AUTO_PAGING_TO_ARRAY_MAX = 1e4;
|
|
979
|
+
/**
|
|
980
|
+
* Iterators stop rather than loop: a page that says more follow must not hand back a cursor this
|
|
981
|
+
* iteration has already sent, which would repeat the same pages forever.
|
|
982
|
+
*/
|
|
983
|
+
const assertNewCursor = (sent, cursor) => {
|
|
984
|
+
if (sent.has(cursor)) throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
985
|
+
message: "The API returned a cursor it had already returned, with more pages to follow",
|
|
986
|
+
details: { cursor }
|
|
987
|
+
});
|
|
988
|
+
sent.add(cursor);
|
|
989
|
+
};
|
|
990
|
+
/** The cursor each page was requested with, for iteration's repeated-cursor check. */
|
|
991
|
+
const requestCursors = /* @__PURE__ */ new WeakMap();
|
|
992
|
+
const autoPaging = (first) => {
|
|
993
|
+
async function* items() {
|
|
994
|
+
let page = await first;
|
|
995
|
+
const start = requestCursors.get(page);
|
|
996
|
+
const sent = new Set(start === void 0 ? [] : [start]);
|
|
997
|
+
for (;;) {
|
|
998
|
+
const more = page.hasNextPage();
|
|
999
|
+
if (more) assertNewCursor(sent, page.nextCursor);
|
|
1000
|
+
yield* page.items;
|
|
1001
|
+
if (!more) return;
|
|
1002
|
+
page = await page.getNextPage();
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return {
|
|
1006
|
+
[Symbol.asyncIterator]: () => items(),
|
|
1007
|
+
async autoPagingToArray(options) {
|
|
1008
|
+
const limit = options?.limit;
|
|
1009
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 1e4) throw invalidArgument(`autoPagingToArray needs a limit from 1 to ${AUTO_PAGING_TO_ARRAY_MAX}; iterate with for await for more`);
|
|
1010
|
+
const collected = [];
|
|
1011
|
+
for await (const item of items()) {
|
|
1012
|
+
collected.push(item);
|
|
1013
|
+
if (collected.length >= limit) break;
|
|
1014
|
+
}
|
|
1015
|
+
return collected;
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
};
|
|
1019
|
+
const toListPage = (data, source, cursor) => {
|
|
1020
|
+
if (!data || typeof data !== "object" || !Array.isArray(data.items)) throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, { message: "The API returned a list without items" });
|
|
1021
|
+
const hasNextPage = () => data.hasMore === true && typeof data.nextCursor === "string" && data.nextCursor !== "" && (source.feed || data.items.length > 0);
|
|
1022
|
+
const page = data;
|
|
1023
|
+
if (cursor !== void 0) requestCursors.set(page, cursor);
|
|
1024
|
+
const self = Promise.resolve(page);
|
|
1025
|
+
const { [Symbol.asyncIterator]: iterate, autoPagingToArray } = autoPaging(self);
|
|
1026
|
+
Object.defineProperties(page, {
|
|
1027
|
+
hasNextPage: {
|
|
1028
|
+
value: hasNextPage,
|
|
1029
|
+
configurable: true
|
|
1030
|
+
},
|
|
1031
|
+
getNextPage: {
|
|
1032
|
+
value: () => {
|
|
1033
|
+
const next = data.nextCursor ?? void 0;
|
|
1034
|
+
return list(async () => {
|
|
1035
|
+
if (!hasNextPage()) throw invalidArgument("There is no next page; check hasNextPage() first");
|
|
1036
|
+
if (next !== void 0 && next === cursor) assertNewCursor(/* @__PURE__ */ new Set([next]), next);
|
|
1037
|
+
return toListPage(await source.fetchPage(next), source, next);
|
|
1038
|
+
});
|
|
1039
|
+
},
|
|
1040
|
+
configurable: true
|
|
1041
|
+
},
|
|
1042
|
+
autoPagingToArray: {
|
|
1043
|
+
value: autoPagingToArray,
|
|
1044
|
+
configurable: true
|
|
1045
|
+
},
|
|
1046
|
+
[Symbol.asyncIterator]: {
|
|
1047
|
+
value: iterate,
|
|
1048
|
+
configurable: true
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
return page;
|
|
1052
|
+
};
|
|
1053
|
+
const list = (load) => {
|
|
1054
|
+
const first = (async () => load())();
|
|
1055
|
+
return Object.assign(first, autoPaging(first));
|
|
1056
|
+
};
|
|
1057
|
+
/**
|
|
1058
|
+
* A list call: `fetchPage` requests the page at a cursor, the first page at `cursor` (which may
|
|
1059
|
+
* be `undefined`). Failures, including invalid options, reject the promise.
|
|
1060
|
+
*/
|
|
1061
|
+
const listPages = (fetchPage, { cursor, feed = false } = {}) => {
|
|
1062
|
+
const source = {
|
|
1063
|
+
fetchPage,
|
|
1064
|
+
feed
|
|
1065
|
+
};
|
|
1066
|
+
return list(async () => toListPage(await fetchPage(cursor), source, cursor));
|
|
1067
|
+
};
|
|
709
1068
|
// src/client/CalmLensVersion.ts
|
|
710
1069
|
/** This SDK's version, from its package.json. */
|
|
711
|
-
const SDK_VERSION = "0.
|
|
1070
|
+
const SDK_VERSION = "0.26.1";
|
|
712
1071
|
const runtimeName = () => {
|
|
713
1072
|
const runtime = globalThis;
|
|
714
1073
|
if (isReactNativeRuntime()) return "react-native";
|
|
@@ -718,8 +1077,15 @@ const runtimeName = () => {
|
|
|
718
1077
|
if (runtime.process?.versions?.node) return `node/${runtime.process.versions.node}`;
|
|
719
1078
|
return "unknown";
|
|
720
1079
|
};
|
|
721
|
-
/**
|
|
722
|
-
|
|
1080
|
+
/**
|
|
1081
|
+
* The `User-Agent` the SDK sends from server runtimes, e.g. `calmlens-js/0.10.0 (node/22.12.0)`,
|
|
1082
|
+
* followed by the app's `name/version (url)` when `appInfo` names it.
|
|
1083
|
+
*/
|
|
1084
|
+
const getUserAgent = (appInfo) => {
|
|
1085
|
+
const sdk = `calmlens-js/${SDK_VERSION} (${runtimeName()})`;
|
|
1086
|
+
if (!appInfo) return sdk;
|
|
1087
|
+
return `${sdk} ${appInfo.version ? `${appInfo.name}/${appInfo.version}` : appInfo.name}${appInfo.url ? ` (${appInfo.url})` : ""}`;
|
|
1088
|
+
};
|
|
723
1089
|
/** True in a web page, where API keys would be visible to every visitor. */
|
|
724
1090
|
const isBrowserRuntime = () => typeof globalThis.window !== "undefined" && typeof globalThis.document !== "undefined";
|
|
725
1091
|
/** True in a React Native app, where an API key ships inside the app for anyone to extract. */
|
|
@@ -871,6 +1237,7 @@ const responseInfo = (response) => ({
|
|
|
871
1237
|
});
|
|
872
1238
|
/** The `CalmLensError` for a non-2xx response whose body has been read. */
|
|
873
1239
|
const toHttpError = (response, bytes) => {
|
|
1240
|
+
const body = new TextDecoder().decode(bytes.subarray(0, MAX_ERROR_BODY_LENGTH * 4)).slice(0, MAX_ERROR_BODY_LENGTH);
|
|
874
1241
|
let data;
|
|
875
1242
|
try {
|
|
876
1243
|
data = JSON.parse(new TextDecoder().decode(bytes));
|
|
@@ -882,14 +1249,24 @@ const toHttpError = (response, bytes) => {
|
|
|
882
1249
|
message: message ?? code,
|
|
883
1250
|
...info,
|
|
884
1251
|
requestId: info.requestId ?? (typeof requestId === "string" ? requestId : void 0),
|
|
885
|
-
details
|
|
1252
|
+
details,
|
|
1253
|
+
body
|
|
886
1254
|
});
|
|
887
1255
|
}
|
|
888
1256
|
return new CalmLensError(SDK_ERROR_CODES.HTTP_ERROR, {
|
|
889
1257
|
message: `HTTP ${response.status}`,
|
|
890
|
-
...responseInfo(response)
|
|
1258
|
+
...responseInfo(response),
|
|
1259
|
+
body
|
|
891
1260
|
});
|
|
892
1261
|
};
|
|
1262
|
+
/** A URL's path without its query, which can hold viewer claims, for hooks and logs. */
|
|
1263
|
+
const pathOf = (url) => {
|
|
1264
|
+
try {
|
|
1265
|
+
return new URL(url).pathname;
|
|
1266
|
+
} catch {
|
|
1267
|
+
return url.split(/[?#]/)[0] ?? "";
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
893
1270
|
/** Sends requests with the client's credentials, deadlines, retries and response limits. */
|
|
894
1271
|
var CalmLensTransport = class {
|
|
895
1272
|
constructor(settings) {
|
|
@@ -901,12 +1278,42 @@ var CalmLensTransport = class {
|
|
|
901
1278
|
for (const [name, value] of Object.entries(request.headers ?? {})) headers.set(name, value);
|
|
902
1279
|
if (!headers.has("accept") && request.deadline === "body") headers.set("accept", "application/json");
|
|
903
1280
|
if (this.settings.apiKey) headers.set("x-api-key", this.settings.apiKey);
|
|
904
|
-
if (!isBrowserRuntime()) headers.set("user-agent", getUserAgent());
|
|
1281
|
+
if (!isBrowserRuntime()) headers.set("user-agent", getUserAgent(this.settings.appInfo));
|
|
905
1282
|
if (request.idempotencyKey) headers.set("idempotency-key", request.idempotencyKey);
|
|
906
1283
|
return Object.fromEntries(headers.entries());
|
|
907
1284
|
}
|
|
1285
|
+
/** Waits before a retry. Either the client's or the request's signal cancels the wait. */
|
|
1286
|
+
async backoff(ms, request) {
|
|
1287
|
+
const callers = createAttemptSignal(this.signalsFor(request), void 0);
|
|
1288
|
+
try {
|
|
1289
|
+
await this.sleep(ms, callers.signal);
|
|
1290
|
+
} finally {
|
|
1291
|
+
callers.release();
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
signalsFor(request) {
|
|
1295
|
+
return [
|
|
1296
|
+
this.settings.signal,
|
|
1297
|
+
request.signal,
|
|
1298
|
+
request.init?.signal ?? void 0
|
|
1299
|
+
];
|
|
1300
|
+
}
|
|
1301
|
+
maxRetriesFor(request) {
|
|
1302
|
+
return request.maxRetries ?? this.settings.maxRetries;
|
|
1303
|
+
}
|
|
1304
|
+
/** Tells the hook and the logger how an attempt went. Neither ever sees a key or a body. */
|
|
1305
|
+
report(attempt) {
|
|
1306
|
+
const { onAttempt, logger, logLevel } = this.settings;
|
|
1307
|
+
try {
|
|
1308
|
+
onAttempt?.(attempt);
|
|
1309
|
+
} catch {}
|
|
1310
|
+
if (!logger || !logLevel || logLevel === "off") return;
|
|
1311
|
+
const failed = attempt.status === null || attempt.status >= 400;
|
|
1312
|
+
if (logLevel === "debug") logger.debug(describeAttempt(attempt));
|
|
1313
|
+
else if (attempt.delayMs !== null || failed) logger.info(describeAttempt(attempt));
|
|
1314
|
+
}
|
|
908
1315
|
canRetry(request) {
|
|
909
|
-
return this.
|
|
1316
|
+
return this.maxRetriesFor(request) > 0 && (request.method === "GET" || request.method === "HEAD" || !!request.idempotencyKey) && isReplayableBody(request.body);
|
|
910
1317
|
}
|
|
911
1318
|
/**
|
|
912
1319
|
* Sends a request and returns the response, retrying transport failures, timeouts, 429, 500, 502–504 and
|
|
@@ -917,9 +1324,23 @@ var CalmLensTransport = class {
|
|
|
917
1324
|
const fetchImpl = request.fetch ?? this.settings.fetch;
|
|
918
1325
|
const retryable = this.canRetry(request);
|
|
919
1326
|
const headers = this.headersFor(request);
|
|
1327
|
+
const now = this.settings.now ?? Date.now;
|
|
1328
|
+
const path = pathOf(request.url);
|
|
920
1329
|
for (let attemptNumber = 0;; attemptNumber++) {
|
|
921
|
-
const canRetryAgain = retryable && attemptNumber < this.
|
|
922
|
-
const attempt = createAttemptSignal(
|
|
1330
|
+
const canRetryAgain = retryable && attemptNumber < this.maxRetriesFor(request);
|
|
1331
|
+
const attempt = createAttemptSignal(this.signalsFor(request), request.timeoutMs);
|
|
1332
|
+
const started = now();
|
|
1333
|
+
const report = (outcome, delayMs) => this.report({
|
|
1334
|
+
operation: request.operation ?? null,
|
|
1335
|
+
method: request.method,
|
|
1336
|
+
path,
|
|
1337
|
+
attempt: attemptNumber + 1,
|
|
1338
|
+
delayMs,
|
|
1339
|
+
status: outcome.response?.status ?? outcome.error?.status ?? null,
|
|
1340
|
+
requestId: outcome.response?.headers.get("x-request-id") ?? outcome.error?.requestId ?? null,
|
|
1341
|
+
durationMs: Math.max(0, now() - started),
|
|
1342
|
+
errorCode: outcome.error?.code ?? null
|
|
1343
|
+
});
|
|
923
1344
|
let response;
|
|
924
1345
|
try {
|
|
925
1346
|
if (attempt.signal.aborted) throw attempt.signal.reason;
|
|
@@ -944,26 +1365,36 @@ var CalmLensTransport = class {
|
|
|
944
1365
|
attempt.release();
|
|
945
1366
|
const failure = toFailure(cause, attempt);
|
|
946
1367
|
if (canRetryAgain && failure.isRetryable()) {
|
|
947
|
-
|
|
1368
|
+
const delayMs = getRetryDelayMs(attemptNumber);
|
|
1369
|
+
report({ error: failure }, delayMs);
|
|
1370
|
+
await this.backoff(delayMs, request);
|
|
948
1371
|
continue;
|
|
949
1372
|
}
|
|
1373
|
+
report({ error: failure }, null);
|
|
950
1374
|
throw failure;
|
|
951
1375
|
}
|
|
952
1376
|
if (request.deadline === "headers") attempt.clearDeadline();
|
|
953
|
-
if (response.ok)
|
|
954
|
-
response,
|
|
955
|
-
|
|
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 {
|
|
1377
|
+
if (response.ok) {
|
|
1378
|
+
report({ response }, null);
|
|
1379
|
+
return {
|
|
961
1380
|
response,
|
|
962
1381
|
attempt
|
|
963
1382
|
};
|
|
1383
|
+
}
|
|
1384
|
+
if (allowHttpErrors) {
|
|
1385
|
+
const retryAfter = parseRetryAfter(response.headers.get("retry-after"));
|
|
1386
|
+
const delayMs = retryAfter !== void 0 ? retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
1387
|
+
if (!canRetryAgain || !RETRYABLE_STATUSES.has(response.status) || delayMs > 6e4) {
|
|
1388
|
+
report({ response }, null);
|
|
1389
|
+
return {
|
|
1390
|
+
response,
|
|
1391
|
+
attempt
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
report({ response }, delayMs);
|
|
964
1395
|
attempt.release();
|
|
965
1396
|
await response.body?.cancel().catch(() => {});
|
|
966
|
-
await this.
|
|
1397
|
+
await this.backoff(delayMs, request);
|
|
967
1398
|
continue;
|
|
968
1399
|
}
|
|
969
1400
|
let error;
|
|
@@ -976,20 +1407,26 @@ var CalmLensTransport = class {
|
|
|
976
1407
|
}
|
|
977
1408
|
const retryDelayMs = error.retryAfter !== void 0 ? error.retryAfter * 1e3 : getRetryDelayMs(attemptNumber);
|
|
978
1409
|
if (canRetryAgain && retryDelayMs <= 6e4 && error.isRetryable()) {
|
|
979
|
-
|
|
1410
|
+
report({ error }, retryDelayMs);
|
|
1411
|
+
await this.backoff(retryDelayMs, request);
|
|
980
1412
|
continue;
|
|
981
1413
|
}
|
|
1414
|
+
report({ error }, null);
|
|
982
1415
|
throw error;
|
|
983
1416
|
}
|
|
984
1417
|
}
|
|
985
|
-
/**
|
|
1418
|
+
/**
|
|
1419
|
+
* Sends a request and parses its JSON response body. An object or array result carries the
|
|
1420
|
+
* response's status, request ID and headers as its non-enumerable `lastResponse`.
|
|
1421
|
+
*/
|
|
986
1422
|
async json(request) {
|
|
987
1423
|
const { response, attempt } = await this.send(request);
|
|
988
1424
|
try {
|
|
989
1425
|
const bytes = await readBody(response, this.settings.maxResponseBytes);
|
|
990
1426
|
if (bytes.byteLength === 0 && (response.status === 204 || request.method === "DELETE")) return;
|
|
1427
|
+
let data;
|
|
991
1428
|
try {
|
|
992
|
-
|
|
1429
|
+
data = JSON.parse(new TextDecoder().decode(bytes));
|
|
993
1430
|
} catch (cause) {
|
|
994
1431
|
throw new CalmLensError(SDK_ERROR_CODES.INVALID_RESPONSE, {
|
|
995
1432
|
message: `Invalid JSON response (HTTP ${response.status})`,
|
|
@@ -997,6 +1434,12 @@ var CalmLensTransport = class {
|
|
|
997
1434
|
cause
|
|
998
1435
|
});
|
|
999
1436
|
}
|
|
1437
|
+
return withLastResponse(data, {
|
|
1438
|
+
status: response.status,
|
|
1439
|
+
requestId: response.headers.get("x-request-id") ?? void 0,
|
|
1440
|
+
headers: response.headers,
|
|
1441
|
+
idempotencyKey: request.idempotencyKey
|
|
1442
|
+
});
|
|
1000
1443
|
} catch (cause) {
|
|
1001
1444
|
throw toFailure(cause, attempt);
|
|
1002
1445
|
} finally {
|
|
@@ -1411,6 +1854,10 @@ const validateConnectionOptions = (options) => {
|
|
|
1411
1854
|
if (partSizeBytes !== void 0 && (!Number.isSafeInteger(partSizeBytes) || partSizeBytes < 5242880 || partSizeBytes > 67108864)) throw invalidConfig("partSizeBytes must be an integer from 5 MiB (5242880) to 64 MiB (67108864)");
|
|
1412
1855
|
for (const name of ["fetch", "uploadFetch"]) if (options[name] !== void 0 && typeof options[name] !== "function") throw invalidConfig(`${name} must be a function`);
|
|
1413
1856
|
assertHttpUrl("baseUrl", options.baseUrl);
|
|
1857
|
+
const { appInfo, onAttempt, logger } = options;
|
|
1858
|
+
if (appInfo !== void 0 && (!appInfo || typeof appInfo.name !== "string" || !/^[\x21-\x7e]+$/.test(appInfo.name) || appInfo.version !== void 0 && !/^[\x21-\x7e]+$/.test(String(appInfo.version)) || appInfo.url !== void 0 && !/^[\x20-\x7e]+$/.test(String(appInfo.url)))) throw invalidConfig("appInfo needs a name, and a version, without spaces, and a url, in printable ASCII");
|
|
1859
|
+
if (onAttempt !== void 0 && typeof onAttempt !== "function") throw invalidConfig("onAttempt must be a function");
|
|
1860
|
+
if (logger !== void 0 && (!logger || typeof logger.debug !== "function" || typeof logger.info !== "function")) throw invalidConfig("logger must have debug and info methods, as console does");
|
|
1414
1861
|
};
|
|
1415
1862
|
/**
|
|
1416
1863
|
* Checks server client options before the client sets anything up. `CalmLensServerClient` and
|
|
@@ -1437,7 +1884,7 @@ const validateAppClientOptions = (options) => {
|
|
|
1437
1884
|
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");
|
|
1438
1885
|
validateConnectionOptions(options);
|
|
1439
1886
|
};
|
|
1440
|
-
/** Checks
|
|
1887
|
+
/** Checks a client's request defaults. */
|
|
1441
1888
|
const validateRequestOptions = (options) => {
|
|
1442
1889
|
assertInteger("timeoutMs", options.timeoutMs, 1);
|
|
1443
1890
|
assertInteger("uploadTimeoutMs", options.uploadTimeoutMs, 1);
|
|
@@ -1735,11 +2182,11 @@ const pollForDecision = async (retrieve, { timeoutMs = DEFAULT_DECISION_TIMEOUT_
|
|
|
1735
2182
|
if (isAssetDecided(asset)) return asset;
|
|
1736
2183
|
const remaining = deadline - now();
|
|
1737
2184
|
if (remaining <= 0) throw new CalmLensError(SDK_ERROR_CODES.TIMEOUT, {
|
|
1738
|
-
message: `Asset ${asset.id} had no moderation decision after ${timeoutMs}ms (classification status: ${asset.classification.status}, moderation
|
|
2185
|
+
message: `Asset ${asset.id} had no moderation decision after ${timeoutMs}ms (classification status: ${asset.classification.status}, moderation decision: ${asset.classification.moderation.decision})`,
|
|
1739
2186
|
details: {
|
|
1740
2187
|
assetId: asset.id,
|
|
1741
2188
|
classificationStatus: asset.classification.status,
|
|
1742
|
-
|
|
2189
|
+
moderationDecision: asset.classification.moderation.decision
|
|
1743
2190
|
}
|
|
1744
2191
|
});
|
|
1745
2192
|
await sleep(Math.min(delay, remaining), signal);
|
|
@@ -1949,261 +2396,4 @@ const selectModerationContextItems = (items) => {
|
|
|
1949
2396
|
}
|
|
1950
2397
|
return selected;
|
|
1951
2398
|
};
|
|
1952
|
-
|
|
1953
|
-
enumerable: true,
|
|
1954
|
-
get: function() {
|
|
1955
|
-
return API_ERROR_CODES;
|
|
1956
|
-
}
|
|
1957
|
-
});
|
|
1958
|
-
Object.defineProperty(exports, "API_ERROR_DEFINITIONS", {
|
|
1959
|
-
enumerable: true,
|
|
1960
|
-
get: function() {
|
|
1961
|
-
return API_ERROR_DEFINITIONS;
|
|
1962
|
-
}
|
|
1963
|
-
});
|
|
1964
|
-
Object.defineProperty(exports, "CALMLENS_ERROR_CODES", {
|
|
1965
|
-
enumerable: true,
|
|
1966
|
-
get: function() {
|
|
1967
|
-
return CALMLENS_ERROR_CODES;
|
|
1968
|
-
}
|
|
1969
|
-
});
|
|
1970
|
-
Object.defineProperty(exports, "CDN_RESOURCES", {
|
|
1971
|
-
enumerable: true,
|
|
1972
|
-
get: function() {
|
|
1973
|
-
return CDN_RESOURCES;
|
|
1974
|
-
}
|
|
1975
|
-
});
|
|
1976
|
-
Object.defineProperty(exports, "CalmLensError", {
|
|
1977
|
-
enumerable: true,
|
|
1978
|
-
get: function() {
|
|
1979
|
-
return CalmLensError;
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
1982
|
-
Object.defineProperty(exports, "CalmLensTransport", {
|
|
1983
|
-
enumerable: true,
|
|
1984
|
-
get: function() {
|
|
1985
|
-
return CalmLensTransport;
|
|
1986
|
-
}
|
|
1987
|
-
});
|
|
1988
|
-
Object.defineProperty(exports, "DEFAULT_CDN_BASE_URL", {
|
|
1989
|
-
enumerable: true,
|
|
1990
|
-
get: function() {
|
|
1991
|
-
return DEFAULT_CDN_BASE_URL;
|
|
1992
|
-
}
|
|
1993
|
-
});
|
|
1994
|
-
Object.defineProperty(exports, "DOMAIN", {
|
|
1995
|
-
enumerable: true,
|
|
1996
|
-
get: function() {
|
|
1997
|
-
return DOMAIN;
|
|
1998
|
-
}
|
|
1999
|
-
});
|
|
2000
|
-
Object.defineProperty(exports, "MAX_DIRECT_IMAGE_UPLOAD_BYTES", {
|
|
2001
|
-
enumerable: true,
|
|
2002
|
-
get: function() {
|
|
2003
|
-
return MAX_DIRECT_IMAGE_UPLOAD_BYTES;
|
|
2004
|
-
}
|
|
2005
|
-
});
|
|
2006
|
-
Object.defineProperty(exports, "MAX_IMAGE_UPLOAD_BYTES", {
|
|
2007
|
-
enumerable: true,
|
|
2008
|
-
get: function() {
|
|
2009
|
-
return MAX_IMAGE_UPLOAD_BYTES;
|
|
2010
|
-
}
|
|
2011
|
-
});
|
|
2012
|
-
Object.defineProperty(exports, "MAX_NON_IMAGE_UPLOAD_BYTES", {
|
|
2013
|
-
enumerable: true,
|
|
2014
|
-
get: function() {
|
|
2015
|
-
return MAX_NON_IMAGE_UPLOAD_BYTES;
|
|
2016
|
-
}
|
|
2017
|
-
});
|
|
2018
|
-
Object.defineProperty(exports, "MODERATION_CONTEXT_USED_CHARACTERS", {
|
|
2019
|
-
enumerable: true,
|
|
2020
|
-
get: function() {
|
|
2021
|
-
return MODERATION_CONTEXT_USED_CHARACTERS;
|
|
2022
|
-
}
|
|
2023
|
-
});
|
|
2024
|
-
Object.defineProperty(exports, "MODERATION_CONTEXT_USED_ITEMS", {
|
|
2025
|
-
enumerable: true,
|
|
2026
|
-
get: function() {
|
|
2027
|
-
return MODERATION_CONTEXT_USED_ITEMS;
|
|
2028
|
-
}
|
|
2029
|
-
});
|
|
2030
|
-
Object.defineProperty(exports, "SDK_ERROR_CODES", {
|
|
2031
|
-
enumerable: true,
|
|
2032
|
-
get: function() {
|
|
2033
|
-
return SDK_ERROR_CODES;
|
|
2034
|
-
}
|
|
2035
|
-
});
|
|
2036
|
-
Object.defineProperty(exports, "SDK_VERSION", {
|
|
2037
|
-
enumerable: true,
|
|
2038
|
-
get: function() {
|
|
2039
|
-
return SDK_VERSION;
|
|
2040
|
-
}
|
|
2041
|
-
});
|
|
2042
|
-
Object.defineProperty(exports, "appendAssetLocation", {
|
|
2043
|
-
enumerable: true,
|
|
2044
|
-
get: function() {
|
|
2045
|
-
return appendAssetLocation;
|
|
2046
|
-
}
|
|
2047
|
-
});
|
|
2048
|
-
Object.defineProperty(exports, "buildAssetUrl", {
|
|
2049
|
-
enumerable: true,
|
|
2050
|
-
get: function() {
|
|
2051
|
-
return buildAssetUrl;
|
|
2052
|
-
}
|
|
2053
|
-
});
|
|
2054
|
-
Object.defineProperty(exports, "checkOptionKeys", {
|
|
2055
|
-
enumerable: true,
|
|
2056
|
-
get: function() {
|
|
2057
|
-
return checkOptionKeys;
|
|
2058
|
-
}
|
|
2059
|
-
});
|
|
2060
|
-
Object.defineProperty(exports, "checkTransformOptions", {
|
|
2061
|
-
enumerable: true,
|
|
2062
|
-
get: function() {
|
|
2063
|
-
return checkTransformOptions;
|
|
2064
|
-
}
|
|
2065
|
-
});
|
|
2066
|
-
Object.defineProperty(exports, "encodePathSegment", {
|
|
2067
|
-
enumerable: true,
|
|
2068
|
-
get: function() {
|
|
2069
|
-
return encodePathSegment;
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
|
-
Object.defineProperty(exports, "getAssetInfo", {
|
|
2073
|
-
enumerable: true,
|
|
2074
|
-
get: function() {
|
|
2075
|
-
return getAssetInfo;
|
|
2076
|
-
}
|
|
2077
|
-
});
|
|
2078
|
-
Object.defineProperty(exports, "getRejectedUploadMimeTypeError", {
|
|
2079
|
-
enumerable: true,
|
|
2080
|
-
get: function() {
|
|
2081
|
-
return getRejectedUploadMimeTypeError;
|
|
2082
|
-
}
|
|
2083
|
-
});
|
|
2084
|
-
Object.defineProperty(exports, "invalidArgument", {
|
|
2085
|
-
enumerable: true,
|
|
2086
|
-
get: function() {
|
|
2087
|
-
return invalidArgument;
|
|
2088
|
-
}
|
|
2089
|
-
});
|
|
2090
|
-
Object.defineProperty(exports, "invalidConfig", {
|
|
2091
|
-
enumerable: true,
|
|
2092
|
-
get: function() {
|
|
2093
|
-
return invalidConfig;
|
|
2094
|
-
}
|
|
2095
|
-
});
|
|
2096
|
-
Object.defineProperty(exports, "isAcceptedUploadMimeType", {
|
|
2097
|
-
enumerable: true,
|
|
2098
|
-
get: function() {
|
|
2099
|
-
return isAcceptedUploadMimeType;
|
|
2100
|
-
}
|
|
2101
|
-
});
|
|
2102
|
-
Object.defineProperty(exports, "isBrowserRuntime", {
|
|
2103
|
-
enumerable: true,
|
|
2104
|
-
get: function() {
|
|
2105
|
-
return isBrowserRuntime;
|
|
2106
|
-
}
|
|
2107
|
-
});
|
|
2108
|
-
Object.defineProperty(exports, "isReactNativeRuntime", {
|
|
2109
|
-
enumerable: true,
|
|
2110
|
-
get: function() {
|
|
2111
|
-
return isReactNativeRuntime;
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
Object.defineProperty(exports, "normalizeUploadMimeType", {
|
|
2115
|
-
enumerable: true,
|
|
2116
|
-
get: function() {
|
|
2117
|
-
return normalizeUploadMimeType;
|
|
2118
|
-
}
|
|
2119
|
-
});
|
|
2120
|
-
Object.defineProperty(exports, "parseTransformSelector", {
|
|
2121
|
-
enumerable: true,
|
|
2122
|
-
get: function() {
|
|
2123
|
-
return parseTransformSelector;
|
|
2124
|
-
}
|
|
2125
|
-
});
|
|
2126
|
-
Object.defineProperty(exports, "pollForDecision", {
|
|
2127
|
-
enumerable: true,
|
|
2128
|
-
get: function() {
|
|
2129
|
-
return pollForDecision;
|
|
2130
|
-
}
|
|
2131
|
-
});
|
|
2132
|
-
Object.defineProperty(exports, "randomUuid", {
|
|
2133
|
-
enumerable: true,
|
|
2134
|
-
get: function() {
|
|
2135
|
-
return randomUuid;
|
|
2136
|
-
}
|
|
2137
|
-
});
|
|
2138
|
-
Object.defineProperty(exports, "selectModerationContextItems", {
|
|
2139
|
-
enumerable: true,
|
|
2140
|
-
get: function() {
|
|
2141
|
-
return selectModerationContextItems;
|
|
2142
|
-
}
|
|
2143
|
-
});
|
|
2144
|
-
Object.defineProperty(exports, "serializeTransform", {
|
|
2145
|
-
enumerable: true,
|
|
2146
|
-
get: function() {
|
|
2147
|
-
return serializeTransform;
|
|
2148
|
-
}
|
|
2149
|
-
});
|
|
2150
|
-
Object.defineProperty(exports, "sleep", {
|
|
2151
|
-
enumerable: true,
|
|
2152
|
-
get: function() {
|
|
2153
|
-
return sleep;
|
|
2154
|
-
}
|
|
2155
|
-
});
|
|
2156
|
-
Object.defineProperty(exports, "stringifyQuery", {
|
|
2157
|
-
enumerable: true,
|
|
2158
|
-
get: function() {
|
|
2159
|
-
return stringifyQuery;
|
|
2160
|
-
}
|
|
2161
|
-
});
|
|
2162
|
-
Object.defineProperty(exports, "toTextAssetOptions", {
|
|
2163
|
-
enumerable: true,
|
|
2164
|
-
get: function() {
|
|
2165
|
-
return toTextAssetOptions;
|
|
2166
|
-
}
|
|
2167
|
-
});
|
|
2168
|
-
Object.defineProperty(exports, "toUrlViewerClaims", {
|
|
2169
|
-
enumerable: true,
|
|
2170
|
-
get: function() {
|
|
2171
|
-
return toUrlViewerClaims;
|
|
2172
|
-
}
|
|
2173
|
-
});
|
|
2174
|
-
Object.defineProperty(exports, "transformSelector", {
|
|
2175
|
-
enumerable: true,
|
|
2176
|
-
get: function() {
|
|
2177
|
-
return transformSelector;
|
|
2178
|
-
}
|
|
2179
|
-
});
|
|
2180
|
-
Object.defineProperty(exports, "validateAppClientOptions", {
|
|
2181
|
-
enumerable: true,
|
|
2182
|
-
get: function() {
|
|
2183
|
-
return validateAppClientOptions;
|
|
2184
|
-
}
|
|
2185
|
-
});
|
|
2186
|
-
Object.defineProperty(exports, "validateBatchAssetsOptions", {
|
|
2187
|
-
enumerable: true,
|
|
2188
|
-
get: function() {
|
|
2189
|
-
return validateBatchAssetsOptions;
|
|
2190
|
-
}
|
|
2191
|
-
});
|
|
2192
|
-
Object.defineProperty(exports, "validateRequestOptions", {
|
|
2193
|
-
enumerable: true,
|
|
2194
|
-
get: function() {
|
|
2195
|
-
return validateRequestOptions;
|
|
2196
|
-
}
|
|
2197
|
-
});
|
|
2198
|
-
Object.defineProperty(exports, "validateServerClientOptions", {
|
|
2199
|
-
enumerable: true,
|
|
2200
|
-
get: function() {
|
|
2201
|
-
return validateServerClientOptions;
|
|
2202
|
-
}
|
|
2203
|
-
});
|
|
2204
|
-
Object.defineProperty(exports, "validateSignAssetUrlOptions", {
|
|
2205
|
-
enumerable: true,
|
|
2206
|
-
get: function() {
|
|
2207
|
-
return validateSignAssetUrlOptions;
|
|
2208
|
-
}
|
|
2209
|
-
});
|
|
2399
|
+
export { CalmLensPayloadTooLargeError as $, normalizeUploadMimeType as A, resolveLogLevel as B, validateBatchAssetsOptions as C, MAX_IMAGE_UPLOAD_BYTES as D, MAX_DIRECT_IMAGE_UPLOAD_BYTES as E, isReactNativeRuntime as F, CalmLensCancelledError as G, CalmLensApiError as H, AUTO_PAGING_TO_ARRAY_MAX as I, CalmLensConnectionError as J, CalmLensConfigurationError as K, copyLastResponse as L, sleep as M, SDK_VERSION as N, MAX_NON_IMAGE_UPLOAD_BYTES as O, isBrowserRuntime as P, CalmLensNotFoundError as Q, listPages as R, validateAppClientOptions as S, DOMAIN as T, CalmLensAuthenticationError as U, CALMLENS_ERROR_CODES as V, CalmLensBadRequestError as W, CalmLensInvalidArgumentError as X, CalmLensError as Y, CalmLensInvalidResponseError as Z, randomUuid as _, appendAssetLocation as a, CalmLensWebhookVerificationError as at, toTextAssetOptions as b, toUrlViewerClaims as c, invalidConfig as ct, checkOptionKeys as d, CalmLensPermissionDeniedError as et, checkTransformOptions as f, pollForDecision as g, parseTransformSelector as h, CDN_RESOURCES as i, CalmLensUnprocessableEntityError as it, CalmLensTransport as j, getRejectedUploadMimeTypeError as k, validateSignAssetUrlOptions as l, API_ERROR_CODES as lt, isAcceptedUploadMimeType as m, MODERATION_CONTEXT_USED_ITEMS as n, CalmLensServerError as nt, buildAssetUrl as o, SDK_ERROR_CODES as ot, encodePathSegment as p, CalmLensConflictError as q, selectModerationContextItems as r, CalmLensTimeoutError as rt, getAssetInfo as s, invalidArgument as st, MODERATION_CONTEXT_USED_CHARACTERS as t, CalmLensRateLimitError as tt, DEFAULT_CDN_BASE_URL as u, API_ERROR_DEFINITIONS as ut, serializeTransform as v, validateServerClientOptions as w, transformSelector as x, stringifyQuery as y, readEnv as z };
|