calmlens 0.25.0 → 0.27.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 +15 -15
- package/bin/calmlens.js +2383 -677
- package/cjs/{BrowserUpload-AO2-2U5Z.js → BrowserUpload-CTqIjCV5.js} +1 -1
- package/{esm/BrowserUpload-D2lemMIU.d.ts → cjs/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{esm/CalmLensAppClient-Dt0t9Bk6.d.ts → cjs/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/cjs/{CalmLensAppClient-nv6qwja0.js → CalmLensAppClient-CZm-9g22.js} +23 -16
- package/cjs/{CalmLensOptionKeys-BvCac9NO.js → CalmLensOptionKeys-C1w3SqmL.js} +165 -95
- package/cjs/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/cjs/{CalmLensServerClient-B60kCBCR.js → CalmLensServerClient-ucq3ITjd.js} +281 -315
- package/cjs/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/cjs/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/cjs/{Core-Cw4IxFUq.js → Core-D-1KCqT7.js} +39 -16
- package/cjs/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{esm/ModerationContextLimits-Bqr0duav.js → cjs/ModerationContextLimits-BcYKgU2X.js} +859 -44
- package/cjs/ReactUpload-BTciTpwB.d.ts +27 -0
- package/cjs/{ReactUpload--oDFltw2.js → ReactUpload-BymgWiC8.js} +38 -2
- package/cjs/{TestTriggers-CiFcTHX3-BmfH4J3f.js → TestTriggers-Cvi7e2KA-DcT1pc_W.js} +91 -22
- package/{esm/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → cjs/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/cjs/{UploadController-ObdgTaBl.js → UploadController-C8GPbDKI.js} +16 -3
- package/{esm/WebhookPayload-DLGGOGW6.d.ts → cjs/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/cjs/app.d.ts +6 -6
- package/cjs/app.js +20 -2
- package/cjs/elements.d.ts +5 -5
- package/cjs/elements.js +105 -68
- package/cjs/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/cjs/index.d.ts +5 -5
- package/cjs/index.js +19 -1
- package/cjs/react-native.d.ts +3 -3
- package/cjs/react-native.js +7 -5
- package/cjs/react.d.ts +5 -4
- package/cjs/react.js +11 -15
- package/cjs/server.d.ts +6 -6
- package/cjs/server.js +20 -2
- package/cjs/test-inputs.d.ts +1 -1
- package/cjs/test-inputs.js +13 -13
- package/cjs/testing.d.ts +18 -21
- package/cjs/testing.js +99 -147
- package/cjs/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.d.ts} +2 -2
- package/cjs/{ui-CA16jyfZ.js → ui-CW8BqtZk.js} +7 -5
- package/cjs/ui.d.ts +3 -3
- package/cjs/ui.js +4 -3
- package/cjs/vue.d.ts +15 -8
- package/cjs/vue.js +30 -17
- package/esm/{BrowserUpload-Co4T6uGk.js → BrowserUpload-C01iLeOs.js} +1 -1
- package/{cjs/BrowserUpload-D2lemMIU.d.ts → esm/BrowserUpload-D4sEmd0X.d.ts} +2 -2
- package/{cjs/CalmLensAppClient-Dt0t9Bk6.d.ts → esm/CalmLensAppClient-CCeFnKX8.d.ts} +5 -11
- package/esm/{CalmLensAppClient-BRzy4dwn.js → CalmLensAppClient-CgDogQQC.js} +23 -16
- package/esm/{CalmLensOptionKeys-bE3rb5PN.js → CalmLensOptionKeys-CEwNbpEz.js} +160 -96
- package/esm/CalmLensServerClient-B7PfocET.d.ts +346 -0
- package/esm/{CalmLensServerClient-_PRi90wI.js → CalmLensServerClient-TT6zrAG5.js} +281 -315
- package/esm/{CalmLensTypes-BhR7LFDu.d.ts → CalmLensTypes-HUERg5hI.d.ts} +142 -155
- package/esm/{Classification-CxRedzgH-C9qlYW_J.d.ts → Classification-CMM2tZpJ-IdIh63n0.d.ts} +6 -7
- package/esm/{Core-CtbYmeXG.js → Core-CP6NaqJz.js} +39 -16
- package/esm/{Core-DSMxC2GL.d.ts → Core-DXAs8mcx.d.ts} +10 -3
- package/{cjs/ModerationContextLimits-Cn9RvnZH.js → esm/ModerationContextLimits-BmV8QD32.js} +476 -301
- package/esm/{ReactUpload-B5itHBSF.js → ReactUpload-B72Oq3qE.js} +34 -4
- package/esm/ReactUpload-BTciTpwB.d.ts +27 -0
- package/esm/{TestTriggers-CiFcTHX3-BK2-sgOC.js → TestTriggers-Cvi7e2KA-BA83CRJb.js} +87 -23
- package/{cjs/TestTriggers-BJ4B-MXR-D1tGifPU.d.ts → esm/TestTriggers-Dnukm-jm-DoEB7jJc.d.ts} +1 -1
- package/esm/{UploadController-C7fL3Iz9.js → UploadController-Q7xTqh5w.js} +11 -4
- package/{cjs/WebhookPayload-DLGGOGW6.d.ts → esm/WebhookPayload-mUmOFH55.d.ts} +152 -9
- package/esm/app.d.ts +6 -6
- package/esm/app.js +3 -3
- package/esm/elements.d.ts +5 -5
- package/esm/elements.js +105 -69
- package/esm/{index-AAWuerkU.d.ts → index-Ck7x1YjM.d.ts} +3 -3
- package/esm/index.d.ts +5 -5
- package/esm/index.js +1 -1
- package/esm/react-native.d.ts +3 -3
- package/esm/react-native.js +6 -6
- package/esm/react.d.ts +5 -4
- package/esm/react.js +10 -16
- package/esm/server.d.ts +6 -6
- package/esm/server.js +3 -3
- package/esm/styles.css +37 -14
- package/esm/svelte/CalmLensAsset.svelte +1 -1
- 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/test-inputs.d.ts +1 -1
- package/esm/test-inputs.js +1 -1
- package/esm/testing.d.ts +18 -21
- package/esm/testing.js +93 -141
- package/esm/{ui-B98AucZA.js → ui-BBDJJkFL.js} +7 -5
- package/esm/{ui-CcuGKTcL.d.ts → ui-BfJNO3c6.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 +30 -19
- 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
package/esm/styles.css
CHANGED
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
.calmlens-uploader *, .calmlens-asset * { box-sizing: border-box; }
|
|
20
20
|
.calmlens-uploader { display: grid; gap: 12px; }
|
|
21
|
-
.calmlens-uploader > [hidden]
|
|
21
|
+
.calmlens-uploader > [hidden],
|
|
22
|
+
.calmlens-uploader .calmlens-upload [hidden] { display: none; }
|
|
22
23
|
.calmlens-dropzone {
|
|
23
24
|
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
|
|
24
25
|
padding: 40px 24px; text-align: center;
|
|
@@ -90,16 +91,31 @@
|
|
|
90
91
|
.calmlens-upload__size { font-size: 0.875em; color: var(--calmlens-muted); }
|
|
91
92
|
.calmlens-upload__message { font-size: 0.875em; margin: 0; }
|
|
92
93
|
.calmlens-progress {
|
|
93
|
-
|
|
94
|
+
appearance: none; display: block; inline-size: 100%; block-size: 4px;
|
|
95
|
+
border: 0; border-radius: 2px; overflow: clip; background: var(--calmlens-border);
|
|
96
|
+
container-type: inline-size;
|
|
94
97
|
}
|
|
95
|
-
.calmlens-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
.calmlens-progress::-webkit-progress-bar { background: transparent; }
|
|
99
|
+
.calmlens-progress::-webkit-progress-value {
|
|
100
|
+
background: var(--calmlens-accent); border-radius: 2px; animation: var(--calmlens-progress-animation, none);
|
|
98
101
|
}
|
|
99
|
-
.calmlens-progress
|
|
100
|
-
|
|
102
|
+
.calmlens-progress::-moz-progress-bar {
|
|
103
|
+
background: var(--calmlens-accent); border-radius: 2px; animation: var(--calmlens-progress-animation, none);
|
|
104
|
+
}
|
|
105
|
+
.calmlens-progress:indeterminate {
|
|
106
|
+
--calmlens-progress-animation: calmlens-indeterminate 1.1s ease-in-out infinite;
|
|
107
|
+
}
|
|
108
|
+
.calmlens-progress:indeterminate:where(:dir(rtl)) {
|
|
109
|
+
--calmlens-progress-animation: calmlens-indeterminate 1.1s ease-in-out infinite reverse;
|
|
110
|
+
}
|
|
111
|
+
@keyframes calmlens-indeterminate {
|
|
112
|
+
from, to { inline-size: 35%; margin-right: auto; }
|
|
113
|
+
from { translate: -100%; }
|
|
114
|
+
to { translate: 100cqi; }
|
|
115
|
+
}
|
|
116
|
+
@keyframes calmlens-indeterminate-still {
|
|
117
|
+
from, to { inline-size: 35%; margin-inline: auto; }
|
|
101
118
|
}
|
|
102
|
-
@keyframes calmlens-indeterminate { from { left: -35%; } to { left: 100%; } }
|
|
103
119
|
.calmlens-upload__actions { display: flex; gap: 8px; align-items: center; }
|
|
104
120
|
.calmlens-icon-button {
|
|
105
121
|
display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 8px; cursor: pointer;
|
|
@@ -107,14 +123,18 @@
|
|
|
107
123
|
}
|
|
108
124
|
.calmlens-icon-button:hover { background: color-mix(in srgb, var(--calmlens-accent) 8%, transparent); border-color: var(--calmlens-border); }
|
|
109
125
|
@media (prefers-reduced-motion: reduce) {
|
|
110
|
-
.calmlens-
|
|
111
|
-
.calmlens-progress:
|
|
126
|
+
.calmlens-dropzone, .calmlens-dropzone__icon, .calmlens-asset__content { transition: none; }
|
|
127
|
+
.calmlens-progress:indeterminate {
|
|
128
|
+
--calmlens-progress-animation: calmlens-indeterminate-still 1s both;
|
|
129
|
+
}
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
.calmlens-asset {
|
|
115
133
|
position: relative; display: block; overflow: hidden; margin: 0; border-radius: var(--calmlens-media-radius, 0);
|
|
116
134
|
background: var(--calmlens-surface);
|
|
117
135
|
}
|
|
136
|
+
/* The average colour stands in while the content loads; transparent content and notices show the surface. */
|
|
137
|
+
.calmlens-asset:not([data-state="loaded"], [data-state="error"], [data-kind="unavailable"]) { background-color: var(--calmlens-average-color, var(--calmlens-surface)); }
|
|
118
138
|
.calmlens-asset__placeholder, .calmlens-asset__content {
|
|
119
139
|
position: absolute; inset: 0; width: 100%; height: 100%; object-fit: var(--calmlens-fit, contain);
|
|
120
140
|
object-position: var(--calmlens-position, center);
|
|
@@ -129,8 +149,8 @@
|
|
|
129
149
|
/* Documents, text and spreadsheets fill the box with their viewer; a document shows its first
|
|
130
150
|
page's still and an open link until the viewer loads. */
|
|
131
151
|
.calmlens-asset__viewer { position: absolute; inset: 0; }
|
|
132
|
-
|
|
133
|
-
.calmlens-asset:not([data-sized])[data-kind="spreadsheet"] { height: 480px; }
|
|
152
|
+
/* A default height only: any height the page gives the element (a class, a style) wins. */
|
|
153
|
+
:where(.calmlens-asset:not([data-sized]):is([data-kind="document"], [data-kind="text"], [data-kind="spreadsheet"])) { height: 480px; }
|
|
134
154
|
.calmlens-asset[data-kind="document"] .calmlens-asset__content { opacity: 1; }
|
|
135
155
|
.calmlens-asset__open { position: absolute; right: 8px; bottom: 8px; text-decoration: none; }
|
|
136
156
|
/* A website's screenshot scrolls beneath the link to its page. */
|
|
@@ -160,7 +180,9 @@
|
|
|
160
180
|
}
|
|
161
181
|
.calmlens-asset__notice p { margin: 0; display: flex; gap: 6px; align-items: center; }
|
|
162
182
|
/* Thumbnails keep the notice's icon and leave its text to screen readers. */
|
|
163
|
-
|
|
183
|
+
/* A notice has no content of its own to size the box, so it can always measure its width. */
|
|
184
|
+
.calmlens-asset[data-sized], .calmlens-asset[data-kind="unavailable"], .calmlens-asset[data-kind="age-restricted"],
|
|
185
|
+
.calmlens-asset[data-state="error"] { container-type: inline-size; }
|
|
164
186
|
@container (max-width: 119px) {
|
|
165
187
|
.calmlens-asset__label, .calmlens-asset__notice > strong, .calmlens-asset__notice > p:not(:has(svg)) {
|
|
166
188
|
position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
|
|
@@ -230,7 +252,8 @@
|
|
|
230
252
|
margin: 0 auto; padding: 20px 24px; max-width: 75ch; white-space: pre-wrap; overflow-wrap: anywhere;
|
|
231
253
|
font-family: inherit; font-size: 1rem; line-height: 1.6;
|
|
232
254
|
}
|
|
233
|
-
|
|
255
|
+
/* Fit to width, the page fills the viewer edge to edge; zoomed out, it sits centred. */
|
|
256
|
+
.calmlens-viewer__pages { flex: 1; min-height: 0; overflow: auto; text-align: center; }
|
|
234
257
|
.calmlens-viewer__page { display: inline-block; position: relative; vertical-align: top; }
|
|
235
258
|
.calmlens-viewer__page canvas { display: block; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); }
|
|
236
259
|
.calmlens-viewer__page-field { width: 4.5em; min-height: 36px; padding: 4px 6px; font: inherit; border: 1px solid var(--calmlens-border); border-radius: calc(var(--calmlens-radius) / 2); background: transparent; color: inherit; }
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
data-sized={ratio ? "" : undefined}
|
|
193
193
|
aria-busy={view.kind === "pending" ? "true" : undefined}
|
|
194
194
|
style:aspect-ratio={ratio}
|
|
195
|
-
style
|
|
195
|
+
style:--calmlens-average-color={sessionState.info?.content?.preview?.averageColor ?? undefined}
|
|
196
196
|
style:--calmlens-fit={fit}
|
|
197
197
|
>
|
|
198
198
|
{#if placeholderUrl}
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
describeUploadItem,
|
|
7
7
|
resolveMessages,
|
|
8
8
|
type UploaderProps,
|
|
9
|
+
withProvidedOptions,
|
|
9
10
|
} from "../ui.js";
|
|
11
|
+
import { getCalmLensContext } from "./context.js";
|
|
10
12
|
import Icon from "./Icon.svelte";
|
|
11
13
|
|
|
12
14
|
let {
|
|
@@ -17,10 +19,12 @@
|
|
|
17
19
|
...options
|
|
18
20
|
}: UploaderProps = $props();
|
|
19
21
|
|
|
22
|
+
// What a setCalmLensContext above gives, under the uploader's own options.
|
|
23
|
+
const provided = getCalmLensContext();
|
|
20
24
|
// The latest options, without restarting uploads when the parent re-renders.
|
|
21
|
-
const own = createUploadController(options);
|
|
25
|
+
const own = createUploadController(withProvidedOptions(provided, { ...options }));
|
|
22
26
|
$effect.pre(() => {
|
|
23
|
-
if (!external) own.setOptions({ ...options });
|
|
27
|
+
if (!external) own.setOptions(withProvidedOptions(provided, { ...options }));
|
|
24
28
|
});
|
|
25
29
|
onMount(() => () => own.clear());
|
|
26
30
|
|
|
@@ -114,21 +118,17 @@
|
|
|
114
118
|
<span class="calmlens-upload__name">{item.file.name}</span>
|
|
115
119
|
<span class="calmlens-upload__size">{itemView.size}</span>
|
|
116
120
|
{#if itemView.busy}
|
|
117
|
-
|
|
118
|
-
class="calmlens-progress"
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
? undefined
|
|
129
|
-
: `${itemView.progressPercent}%`}
|
|
130
|
-
></div>
|
|
131
|
-
</div>
|
|
121
|
+
{#if itemView.progressPercent === undefined}
|
|
122
|
+
<progress class="calmlens-progress" aria-label={itemView.message} max={100}
|
|
123
|
+
></progress>
|
|
124
|
+
{:else}
|
|
125
|
+
<progress
|
|
126
|
+
class="calmlens-progress"
|
|
127
|
+
aria-label={itemView.message}
|
|
128
|
+
max={100}
|
|
129
|
+
value={itemView.progressPercent}
|
|
130
|
+
></progress>
|
|
131
|
+
{/if}
|
|
132
132
|
{/if}
|
|
133
133
|
{#if itemView.message}
|
|
134
134
|
<p class="calmlens-upload__message" role="status">{itemView.message}</p>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The upload options `setCalmLensContext` gives every `CalmLensUploader` beneath a component.
|
|
2
|
+
|
|
3
|
+
import { getContext, setContext } from "svelte";
|
|
4
|
+
import { withProvidedOptions } from "../ui.js";
|
|
5
|
+
|
|
6
|
+
const KEY = Symbol("calmlens");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Gives every `CalmLensUploader` in this component's descendants these upload options, such as
|
|
10
|
+
* `uploadPresetId` and `tokenUrl`, so they needn't be passed to each one. Call it while the
|
|
11
|
+
* component initialises. An option an uploader sets itself wins, and a nested call adds to the
|
|
12
|
+
* outer one's options.
|
|
13
|
+
*
|
|
14
|
+
* @param {import("../ui.js").CalmLensProvidedOptions} options
|
|
15
|
+
*/
|
|
16
|
+
export const setCalmLensContext = (options) => {
|
|
17
|
+
setContext(KEY, withProvidedOptions(getContext(KEY), options));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The options the nearest `setCalmLensContext` gave, if any. */
|
|
21
|
+
export const getCalmLensContext = () => getContext(KEY);
|
package/esm/svelte/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Component, Snippet } from "svelte";
|
|
2
2
|
import type {
|
|
3
3
|
AssetProps,
|
|
4
|
+
CalmLensProvidedOptions,
|
|
4
5
|
CalmLensUpload as CoreCalmLensUpload,
|
|
5
6
|
UploadControllerOptions as CoreUploadControllerOptions,
|
|
6
7
|
UploaderProps as CoreUploaderProps,
|
|
@@ -21,6 +22,17 @@ export type CalmLensUpload<F extends UploadFile = File> = CoreCalmLensUpload<F>;
|
|
|
21
22
|
export type UploadSnapshot<F extends UploadFile = File> = CoreUploadSnapshot<F>;
|
|
22
23
|
export type UploadControllerOptions<F extends UploadFile = File> = CoreUploadControllerOptions<F>;
|
|
23
24
|
export type UploaderProps<F extends UploadFile = File> = CoreUploaderProps<F>;
|
|
25
|
+
/**
|
|
26
|
+
* Gives every `CalmLensUploader` in this component's descendants these upload options, such as
|
|
27
|
+
* `uploadPresetId` and `tokenUrl`. Call it while the component initialises. An option an uploader
|
|
28
|
+
* sets itself wins, and a nested call adds to the outer one's options.
|
|
29
|
+
*/
|
|
30
|
+
export declare const setCalmLensContext: <F extends UploadFile = File>(
|
|
31
|
+
options: CalmLensProvidedOptions<F>,
|
|
32
|
+
) => void;
|
|
33
|
+
/** The options the nearest `setCalmLensContext` gave, if any. */
|
|
34
|
+
export declare const getCalmLensContext: () => CalmLensProvidedOptions<File> | undefined;
|
|
35
|
+
|
|
24
36
|
/** Creates an upload queue for the components, such as one a form starts on submit. */
|
|
25
37
|
export declare const createUploadController: <F extends UploadFile = File>(
|
|
26
38
|
options: UploadControllerOptions<F>,
|
package/esm/svelte/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export { default as CalmLensSpreadsheetViewer } from "./CalmLensSpreadsheetViewe
|
|
|
9
9
|
export { default as CalmLensTextViewer } from "./CalmLensTextViewer.svelte";
|
|
10
10
|
export { default as CalmLensUploader } from "./CalmLensUploader.svelte";
|
|
11
11
|
export { default as CalmLensWebsiteViewer } from "./CalmLensWebsiteViewer.svelte";
|
|
12
|
+
export { getCalmLensContext, setCalmLensContext } from "./context.js";
|
package/esm/test-inputs.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TEST_FACE_AGE_PRESETS, c as TestDetections, d as detectTestTrigger, f as generateTestTextCode, h as testInputForSignal, i as TEST_FACE_AGE_MAX, l as TestInput, m as paintTestImage, n as TEST_DETECTIONS_MAX, o as TEST_INPUT_KEY_PATTERN, p as getImageTestCategories, r as TEST_DETECTION_BOX_MAX, s as TEST_INPUT_PRESETS, t as ClassificationTestSignal, u as detectTestImage } from "./TestTriggers-
|
|
1
|
+
import { a as TEST_FACE_AGE_PRESETS, c as TestDetections, d as detectTestTrigger, f as generateTestTextCode, h as testInputForSignal, i as TEST_FACE_AGE_MAX, l as TestInput, m as paintTestImage, n as TEST_DETECTIONS_MAX, o as TEST_INPUT_KEY_PATTERN, p as getImageTestCategories, r as TEST_DETECTION_BOX_MAX, s as TEST_INPUT_PRESETS, t as ClassificationTestSignal, u as detectTestImage } from "./TestTriggers-Dnukm-jm-DoEB7jJc.js";
|
|
2
2
|
export { type ClassificationTestSignal, TEST_DETECTIONS_MAX, TEST_DETECTION_BOX_MAX, TEST_FACE_AGE_MAX, TEST_FACE_AGE_PRESETS, TEST_INPUT_KEY_PATTERN, TEST_INPUT_PRESETS, type TestDetections, type TestInput, detectTestImage, detectTestTrigger, generateTestTextCode, getImageTestCategories, paintTestImage, testInputForSignal };
|
package/esm/test-inputs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as TEST_DETECTIONS_MAX, n as TEST_DETECTION_BOX_MAX, r as TEST_FACE_AGE_MAX, i as TEST_FACE_AGE_PRESETS, a as TEST_INPUT_KEY_PATTERN, o as TEST_INPUT_PRESETS, s as detectTestImage, c as detectTestTrigger, l as generateTestTextCode, u as getImageTestCategories, f as paintTestImage, p as testInputForSignal } from "./TestTriggers-
|
|
1
|
+
export { t as TEST_DETECTIONS_MAX, n as TEST_DETECTION_BOX_MAX, r as TEST_FACE_AGE_MAX, i as TEST_FACE_AGE_PRESETS, a as TEST_INPUT_KEY_PATTERN, o as TEST_INPUT_PRESETS, s as detectTestImage, c as detectTestTrigger, l as generateTestTextCode, u as getImageTestCategories, f as paintTestImage, p as testInputForSignal } from "./TestTriggers-Cvi7e2KA-BA83CRJb.js";
|
package/esm/testing.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as CalmLensAppClient } from "./CalmLensAppClient-
|
|
3
|
-
import {
|
|
4
|
-
import { t as CalmLensServerClient } from "./CalmLensServerClient-
|
|
5
|
-
import { t as ClassificationTestSignal } from "./TestTriggers-
|
|
1
|
+
import { Fn as AssetBinaryPayloadInput, Ft as SignUploadTokenOptions, Lt as SignedUploadToken, O as CalmLensAppClientOptions, _n as Folder, gn as PermissionGrant, k as CalmLensServerClientOptions, ln as TypedEvent, m as AssetModeration, r as Asset } from "./CalmLensTypes-HUERg5hI.js";
|
|
2
|
+
import { t as CalmLensAppClient } from "./CalmLensAppClient-CCeFnKX8.js";
|
|
3
|
+
import { I as ApiErrorCode, n as WebhookEventPayload } from "./WebhookPayload-mUmOFH55.js";
|
|
4
|
+
import { t as CalmLensServerClient } from "./CalmLensServerClient-B7PfocET.js";
|
|
5
|
+
import { t as ClassificationTestSignal } from "./TestTriggers-Dnukm-jm-DoEB7jJc.js";
|
|
6
6
|
import "zod";
|
|
7
7
|
/**
|
|
8
8
|
* Signs a single-use upload token with `apiKey`, locally. `CalmLensServerClient` and
|
|
@@ -96,7 +96,7 @@ export declare class MockDecision {
|
|
|
96
96
|
* `flaggedCategories`. `requestedAt` is when a pending review joined the queue. `undefined` for
|
|
97
97
|
* `pending` and `failed`.
|
|
98
98
|
*/
|
|
99
|
-
report(requestedAt?: number): Omit<AssetModeration, "
|
|
99
|
+
report(requestedAt?: number): Omit<AssetModeration, "decision" | "manualReviews"> | undefined;
|
|
100
100
|
}
|
|
101
101
|
/** Starts a moderation decision with this status; see `MockDecision`. */
|
|
102
102
|
export declare const mockDecision: (status: MockAssetOutcome) => MockDecision;
|
|
@@ -106,8 +106,6 @@ type MockModerationTrigger =
|
|
|
106
106
|
"upload" |
|
|
107
107
|
/** `assets.retry` queued a failed asset again. */
|
|
108
108
|
"retry" |
|
|
109
|
-
/** `assets.explain` with `rerun: true` queued the asset again. */
|
|
110
|
-
"rerun" |
|
|
111
109
|
/** `completeProcessing(assetId)` finished processing without a decision of its own. */
|
|
112
110
|
"complete";
|
|
113
111
|
/** What `mockOptions.moderate` receives for each asset the mock moderates. */
|
|
@@ -122,13 +120,13 @@ interface MockModerationInput {
|
|
|
122
120
|
trigger: MockModerationTrigger;
|
|
123
121
|
/**
|
|
124
122
|
* `true` when the API would queue the work rather than answer with the decision: queued
|
|
125
|
-
* uploads, retries
|
|
123
|
+
* uploads, retries and `completeProcessing`.
|
|
126
124
|
*/
|
|
127
125
|
queued: boolean;
|
|
128
126
|
}
|
|
129
127
|
/**
|
|
130
128
|
* Decides an asset the mock moderates: a status or a `mockDecision(...)`, or a promise of one.
|
|
131
|
-
* Without it, queued uploads
|
|
129
|
+
* Without it, queued uploads and retries stay `pending` and everything else is `allowed`.
|
|
132
130
|
*/
|
|
133
131
|
type MockModerate = (input: MockModerationInput) => MockAssetOutcome | MockDecision | Promise<MockAssetOutcome | MockDecision>;
|
|
134
132
|
interface MockStoredContent {
|
|
@@ -194,13 +192,13 @@ type MockReviewDecision = "allowed" | "limited" | "age-restricted" | "blocked" |
|
|
|
194
192
|
* method that sends it; `callsTo` and `failNextRequest` also match the others (see
|
|
195
193
|
* `MockCalmLensCall`).
|
|
196
194
|
*/
|
|
197
|
-
declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.
|
|
195
|
+
declare const MOCK_OPERATIONS: readonly ["assets.list", "assets.search", "assets.retrieve", "assets.waitForDecision", "assets.update", "assets.listChildren", "assets.listTimeline", "assets.create", "assets.classify", "assets.uploadPart", "assets.move", "assets.retry", "assets.decide", "assets.removeContent", "assets.delete", "assets.batch", "text.classify", "cdn.serve", "cdn.getAssetInfo", "cdn.signAssetUrl", "events.list", "folders.list", "folders.retrieve", "folders.create", "folders.update", "folders.delete", "folders.move", "hashLists.list", "hashLists.retrieve", "hashLists.create", "hashLists.update", "hashLists.delete", "hashLists.listEntries", "hashLists.addEntry", "hashLists.removeEntry", "policies.list", "policies.retrieve", "policies.create", "policies.update", "policies.reset", "policies.upgrade", "policies.setAutomaticUpdates", "policies.delete", "policies.retrieveAssigned", "policies.assign", "lenses.list", "lenses.create", "lenses.retrieve", "lenses.update", "lenses.delete", "ensureLens", "ensureLenses", "uploadPresets.list", "uploadPresets.ensure", "uploadPresets.delete", "projectSettings.get", "projectSettings.update", "metadataFields.list", "metadataFields.ensure", "metadataFields.delete"];
|
|
198
196
|
type MockCalmLensOperation = (typeof MOCK_OPERATIONS)[number];
|
|
199
197
|
/**
|
|
200
198
|
* One request a mock client sent, as the in-memory API received it. `operation` is the client
|
|
201
199
|
* method that sends it; requests several methods send are recorded under the first: `text.classify`
|
|
202
200
|
* as `assets.classify`, `ensureLens` as `ensureLenses`, `assets.waitForDecision` polls as
|
|
203
|
-
* `assets.retrieve`,
|
|
201
|
+
* `assets.retrieve`, and so on. `callsTo` matches all of
|
|
204
202
|
* them. Methods that send nothing, such as `uploadTokens.sign` or a cached `ensureLens`, are not
|
|
205
203
|
* recorded.
|
|
206
204
|
*/
|
|
@@ -252,7 +250,7 @@ interface MockUploadPreset {
|
|
|
252
250
|
/** Accepted content types, such as `["image/*"]`. Defaults to any type. */
|
|
253
251
|
allowedContentTypes?: string[];
|
|
254
252
|
maxFileSizeInBytes?: number;
|
|
255
|
-
/** Return `classification.moderation.
|
|
253
|
+
/** Return `classification.moderation.decision` to the uploader. Defaults to `true`. */
|
|
256
254
|
showDecisions?: boolean;
|
|
257
255
|
/** Defaults to `public`. */
|
|
258
256
|
visibility?: "public" | "private";
|
|
@@ -260,7 +258,9 @@ interface MockUploadPreset {
|
|
|
260
258
|
retainContent?: boolean;
|
|
261
259
|
folderId?: string | null;
|
|
262
260
|
}
|
|
263
|
-
interface MockCalmLensServerClientOptions extends Omit<CalmLensServerClientOptions, "projectId"> {
|
|
261
|
+
interface MockCalmLensServerClientOptions extends Omit<CalmLensServerClientOptions, "apiKey" | "projectId"> {
|
|
262
|
+
/** A key from `createMockApiKey`, whose grants the mock API enforces. Never read from the environment. */
|
|
263
|
+
apiKey: string;
|
|
264
264
|
/** Defaults to `project-1`. */
|
|
265
265
|
projectId?: string;
|
|
266
266
|
mockOptions?: {
|
|
@@ -282,9 +282,9 @@ interface MockCalmLensServerClientOptions extends Omit<CalmLensServerClientOptio
|
|
|
282
282
|
now?: () => number;
|
|
283
283
|
/**
|
|
284
284
|
* Decides each asset the mock moderates, from the stored asset, its content (bytes, and the
|
|
285
|
-
* text of a plain-text upload) and why it is moderated (`upload`, `retry
|
|
285
|
+
* text of a plain-text upload) and why it is moderated (`upload`, `retry` or
|
|
286
286
|
* `complete`). Return a status or a `mockDecision(...)`, whose report fills the asset's
|
|
287
|
-
* categories and policy. Without it, queued uploads
|
|
287
|
+
* categories and policy. Without it, queued uploads and retries stay `pending` until
|
|
288
288
|
* `completeProcessing`, and everything else is `allowed`.
|
|
289
289
|
*/
|
|
290
290
|
moderate?: MockModerate;
|
|
@@ -356,11 +356,8 @@ export declare class MockCalmLensServerClient extends CalmLensServerClient {
|
|
|
356
356
|
* else what `mockOptions.moderate` returns for the `complete` trigger (`allowed` by default).
|
|
357
357
|
* The asset gets the decision's report, and `asset.classified` and the automated
|
|
358
358
|
* `asset.<status>` (or `asset.failed`) join the events feed. No review is recorded, so the
|
|
359
|
-
* asset can still be moderated again.
|
|
360
|
-
* `
|
|
361
|
-
* `pending` or `failed`. Rejects with `asset/not-found` for an unknown asset and
|
|
362
|
-
* `sdk/invalid-argument` for one that isn't processing or awaiting a pending re-run. It sends
|
|
363
|
-
* no request.
|
|
359
|
+
* asset can still be moderated again. Rejects with `asset/not-found` for an unknown asset and
|
|
360
|
+
* `sdk/invalid-argument` for one that isn't processing. It sends no request.
|
|
364
361
|
*/
|
|
365
362
|
completeProcessing(assetId: string, decision?: MockAssetOutcome | MockDecision): Promise<Asset>;
|
|
366
363
|
}
|