@omnichar/contracts 0.0.0-6cf9984
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/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +42 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/index.d.ts +18 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +13 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/result.d.ts +12 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/result.js +7 -0
- package/dist/result.js.map +1 -0
- package/dist/v1/accessRequests.d.ts +11 -0
- package/dist/v1/accessRequests.d.ts.map +1 -0
- package/dist/v1/accessRequests.js +12 -0
- package/dist/v1/accessRequests.js.map +1 -0
- package/dist/v1/apiKeys.d.ts +38 -0
- package/dist/v1/apiKeys.d.ts.map +1 -0
- package/dist/v1/apiKeys.js +28 -0
- package/dist/v1/apiKeys.js.map +1 -0
- package/dist/v1/assets.d.ts +47 -0
- package/dist/v1/assets.d.ts.map +1 -0
- package/dist/v1/assets.js +24 -0
- package/dist/v1/assets.js.map +1 -0
- package/dist/v1/capacity.d.ts +48 -0
- package/dist/v1/capacity.d.ts.map +1 -0
- package/dist/v1/capacity.js +18 -0
- package/dist/v1/capacity.js.map +1 -0
- package/dist/v1/characterListings.d.ts +75 -0
- package/dist/v1/characterListings.d.ts.map +1 -0
- package/dist/v1/characterListings.js +68 -0
- package/dist/v1/characterListings.js.map +1 -0
- package/dist/v1/characters.d.ts +89 -0
- package/dist/v1/characters.d.ts.map +1 -0
- package/dist/v1/characters.js +64 -0
- package/dist/v1/characters.js.map +1 -0
- package/dist/v1/common.d.ts +13 -0
- package/dist/v1/common.d.ts.map +1 -0
- package/dist/v1/common.js +12 -0
- package/dist/v1/common.js.map +1 -0
- package/dist/v1/credits.d.ts +124 -0
- package/dist/v1/credits.d.ts.map +1 -0
- package/dist/v1/credits.js +82 -0
- package/dist/v1/credits.js.map +1 -0
- package/dist/v1/datasets.d.ts +153 -0
- package/dist/v1/datasets.d.ts.map +1 -0
- package/dist/v1/datasets.js +93 -0
- package/dist/v1/datasets.js.map +1 -0
- package/dist/v1/featureRequests.d.ts +29 -0
- package/dist/v1/featureRequests.d.ts.map +1 -0
- package/dist/v1/featureRequests.js +36 -0
- package/dist/v1/featureRequests.js.map +1 -0
- package/dist/v1/health.d.ts +13 -0
- package/dist/v1/health.d.ts.map +1 -0
- package/dist/v1/health.js +10 -0
- package/dist/v1/health.js.map +1 -0
- package/dist/v1/index.d.ts +23 -0
- package/dist/v1/index.d.ts.map +1 -0
- package/dist/v1/index.js +23 -0
- package/dist/v1/index.js.map +1 -0
- package/dist/v1/me.d.ts +30 -0
- package/dist/v1/me.d.ts.map +1 -0
- package/dist/v1/me.js +22 -0
- package/dist/v1/me.js.map +1 -0
- package/dist/v1/plans.d.ts +30 -0
- package/dist/v1/plans.d.ts.map +1 -0
- package/dist/v1/plans.js +19 -0
- package/dist/v1/plans.js.map +1 -0
- package/dist/v1/purchases.d.ts +40 -0
- package/dist/v1/purchases.d.ts.map +1 -0
- package/dist/v1/purchases.js +56 -0
- package/dist/v1/purchases.js.map +1 -0
- package/dist/v1/runs.d.ts +498 -0
- package/dist/v1/runs.d.ts.map +1 -0
- package/dist/v1/runs.js +203 -0
- package/dist/v1/runs.js.map +1 -0
- package/dist/v1/sessions.d.ts +349 -0
- package/dist/v1/sessions.d.ts.map +1 -0
- package/dist/v1/sessions.js +76 -0
- package/dist/v1/sessions.js.map +1 -0
- package/dist/v1/studio.d.ts +124 -0
- package/dist/v1/studio.d.ts.map +1 -0
- package/dist/v1/studio.js +120 -0
- package/dist/v1/studio.js.map +1 -0
- package/dist/v1/terms.d.ts +8 -0
- package/dist/v1/terms.d.ts.map +1 -0
- package/dist/v1/terms.js +15 -0
- package/dist/v1/terms.js.map +1 -0
- package/dist/v1/uploads.d.ts +56 -0
- package/dist/v1/uploads.d.ts.map +1 -0
- package/dist/v1/uploads.js +58 -0
- package/dist/v1/uploads.js.map +1 -0
- package/dist/v1/usernames.d.ts +35 -0
- package/dist/v1/usernames.d.ts.map +1 -0
- package/dist/v1/usernames.js +67 -0
- package/dist/v1/usernames.js.map +1 -0
- package/dist/v1/videoPricing.d.ts +70 -0
- package/dist/v1/videoPricing.d.ts.map +1 -0
- package/dist/v1/videoPricing.js +128 -0
- package/dist/v1/videoPricing.js.map +1 -0
- package/dist/v1/workflows.d.ts +198 -0
- package/dist/v1/workflows.d.ts.map +1 -0
- package/dist/v1/workflows.js +103 -0
- package/dist/v1/workflows.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { importedAssetKindSchema } from './assets.js';
|
|
3
|
+
// Mirrors OmniChar's own model: clip trains on one file per item, control pairs each with a
|
|
4
|
+
// reference. Only clip is exposed today; the mode exists so a dataset made now keeps its meaning.
|
|
5
|
+
// Long enough for any caption a person writes, and named so the form and the schema agree.
|
|
6
|
+
export const MAX_CAPTION_LENGTH = 2000;
|
|
7
|
+
export const DATASET_MODES = ['clip', 'control'];
|
|
8
|
+
export const datasetModeSchema = z.enum(DATASET_MODES);
|
|
9
|
+
export const datasetSchema = z.object({
|
|
10
|
+
id: z.uuid(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
// Prepended to every caption when a run exports the dataset, never stored on the items.
|
|
13
|
+
triggerWord: z.string(),
|
|
14
|
+
mode: datasetModeSchema,
|
|
15
|
+
itemCount: z.number().int().nonnegative(),
|
|
16
|
+
createdAt: z.iso.datetime(),
|
|
17
|
+
updatedAt: z.iso.datetime(),
|
|
18
|
+
});
|
|
19
|
+
export const datasetItemSchema = z.object({
|
|
20
|
+
id: z.uuid(),
|
|
21
|
+
// The caller's own uploaded file, by the same id the Imported list uses.
|
|
22
|
+
assetId: z.string().max(200),
|
|
23
|
+
name: z.string(),
|
|
24
|
+
kind: importedAssetKindSchema,
|
|
25
|
+
url: z.url(),
|
|
26
|
+
// A small WebP of the same file. Signed without checking it exists, so a client falls back to
|
|
27
|
+
// `url` on a miss rather than paying for an existence check per row.
|
|
28
|
+
thumbUrl: z.url().nullable(),
|
|
29
|
+
caption: z.string(),
|
|
30
|
+
position: z.number().int().nonnegative(),
|
|
31
|
+
});
|
|
32
|
+
export const datasetDetailSchema = datasetSchema.extend({
|
|
33
|
+
items: z.array(datasetItemSchema),
|
|
34
|
+
});
|
|
35
|
+
export const datasetListSchema = z.object({ items: z.array(datasetSchema) });
|
|
36
|
+
export const createDatasetBodySchema = z.object({
|
|
37
|
+
name: z.string().min(1).max(120),
|
|
38
|
+
triggerWord: z.string().max(80).default(''),
|
|
39
|
+
});
|
|
40
|
+
export const updateDatasetBodySchema = z
|
|
41
|
+
.object({
|
|
42
|
+
name: z.string().min(1).max(120).optional(),
|
|
43
|
+
triggerWord: z.string().max(80).optional(),
|
|
44
|
+
mode: datasetModeSchema.optional(),
|
|
45
|
+
})
|
|
46
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change.' });
|
|
47
|
+
export const addDatasetItemsBodySchema = z.object({
|
|
48
|
+
assetIds: z.array(z.string().max(200)).min(1).max(200),
|
|
49
|
+
});
|
|
50
|
+
export const updateDatasetItemBodySchema = z
|
|
51
|
+
.object({
|
|
52
|
+
caption: z.string().max(MAX_CAPTION_LENGTH).optional(),
|
|
53
|
+
position: z.number().int().min(0).max(10_000).optional(),
|
|
54
|
+
})
|
|
55
|
+
.refine((body) => Object.keys(body).length > 0, { message: 'Nothing to change.' });
|
|
56
|
+
// Staging, as OmniChar does it: a source is inspected, then pulled into rows that are reviewed and
|
|
57
|
+
// captioned before anything reaches the set. Import is the only call that changes what will train.
|
|
58
|
+
export const setDatasetItemsBodySchema = z.object({
|
|
59
|
+
items: z
|
|
60
|
+
.array(z.object({
|
|
61
|
+
assetId: z.string().max(200),
|
|
62
|
+
caption: z.string().max(MAX_CAPTION_LENGTH).default(''),
|
|
63
|
+
}))
|
|
64
|
+
.max(1000),
|
|
65
|
+
});
|
|
66
|
+
export const HUGGING_FACE_REPO = /^[A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*$/;
|
|
67
|
+
export const huggingFaceRepoSchema = z.string().regex(HUGGING_FACE_REPO, 'Use owner/name.');
|
|
68
|
+
// What pulling it would get, before committing to it: a video set can be tens of gigabytes.
|
|
69
|
+
export const datasetSourcePreviewSchema = z.object({
|
|
70
|
+
repo: z.string(),
|
|
71
|
+
files: z.number().int().nonnegative(),
|
|
72
|
+
bytes: z.number().int().nonnegative(),
|
|
73
|
+
captioned: z.number().int().nonnegative(),
|
|
74
|
+
// What an import would actually take, once the per-request caps are applied.
|
|
75
|
+
importable: z.number().int().nonnegative(),
|
|
76
|
+
truncated: z.boolean(),
|
|
77
|
+
});
|
|
78
|
+
export const importFromHuggingFaceBodySchema = z.object({
|
|
79
|
+
repo: huggingFaceRepoSchema,
|
|
80
|
+
limit: z.number().int().min(1).max(300).default(100),
|
|
81
|
+
});
|
|
82
|
+
export const stagedItemSchema = z.object({
|
|
83
|
+
assetId: z.string().max(200),
|
|
84
|
+
name: z.string(),
|
|
85
|
+
kind: importedAssetKindSchema,
|
|
86
|
+
url: z.url(),
|
|
87
|
+
// A small WebP of the same file. Signed without checking it exists, so a client falls back to
|
|
88
|
+
// `url` on a miss rather than paying for an existence check per row.
|
|
89
|
+
thumbUrl: z.url().nullable(),
|
|
90
|
+
caption: z.string(),
|
|
91
|
+
});
|
|
92
|
+
export const stagedItemListSchema = z.object({ items: z.array(stagedItemSchema) });
|
|
93
|
+
//# sourceMappingURL=datasets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../src/v1/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Asking for something the product does not do yet, from inside it.
|
|
4
|
+
*
|
|
5
|
+
* Like an access request, the person is read from the verified session rather than the body: a
|
|
6
|
+
* request filed in somebody else's name would be worse than no request at all.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FEATURE_REQUEST_TOPICS: readonly ["api", "licensing", "credits", "nsfw", "feedback", "other"];
|
|
9
|
+
export type FeatureRequestTopic = (typeof FEATURE_REQUEST_TOPICS)[number];
|
|
10
|
+
export declare const FEATURE_REQUEST_LABELS: Record<FeatureRequestTopic, string>;
|
|
11
|
+
export declare const FEATURE_REQUEST_DETAILS_MAX = 1000;
|
|
12
|
+
export declare const featureRequestBodySchema: z.ZodObject<{
|
|
13
|
+
topic: z.ZodEnum<{
|
|
14
|
+
credits: "credits";
|
|
15
|
+
other: "other";
|
|
16
|
+
api: "api";
|
|
17
|
+
licensing: "licensing";
|
|
18
|
+
nsfw: "nsfw";
|
|
19
|
+
feedback: "feedback";
|
|
20
|
+
}>;
|
|
21
|
+
details: z.ZodOptional<z.ZodString>;
|
|
22
|
+
page: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const featureRequestResponseSchema: z.ZodObject<{
|
|
25
|
+
ok: z.ZodLiteral<true>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type FeatureRequestBody = z.infer<typeof featureRequestBodySchema>;
|
|
28
|
+
export type FeatureRequestResponse = z.infer<typeof featureRequestResponseSchema>;
|
|
29
|
+
//# sourceMappingURL=featureRequests.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureRequests.d.ts","sourceRoot":"","sources":["../../src/v1/featureRequests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,uEAOzB,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAIzE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAOtE,CAAA;AAED,eAAO,MAAM,2BAA2B,OAAO,CAAA;AAE/C,eAAO,MAAM,wBAAwB;;;;;;;;;;;iBAKnC,CAAA;AAEF,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AACzE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Asking for something the product does not do yet, from inside it.
|
|
4
|
+
*
|
|
5
|
+
* Like an access request, the person is read from the verified session rather than the body: a
|
|
6
|
+
* request filed in somebody else's name would be worse than no request at all.
|
|
7
|
+
*/
|
|
8
|
+
export const FEATURE_REQUEST_TOPICS = [
|
|
9
|
+
'api',
|
|
10
|
+
'licensing',
|
|
11
|
+
'credits',
|
|
12
|
+
'nsfw',
|
|
13
|
+
'feedback',
|
|
14
|
+
'other',
|
|
15
|
+
];
|
|
16
|
+
// What the team reads in the inbox. Here rather than in the browser so the stored row says what the
|
|
17
|
+
// person picked even if the chip is renamed later.
|
|
18
|
+
export const FEATURE_REQUEST_LABELS = {
|
|
19
|
+
api: 'API access',
|
|
20
|
+
licensing: 'Character Licensing',
|
|
21
|
+
credits: 'Free Credits',
|
|
22
|
+
nsfw: 'NSFW',
|
|
23
|
+
feedback: 'Share feedback',
|
|
24
|
+
other: 'Other',
|
|
25
|
+
};
|
|
26
|
+
export const FEATURE_REQUEST_DETAILS_MAX = 1000;
|
|
27
|
+
export const featureRequestBodySchema = z.object({
|
|
28
|
+
topic: z.enum(FEATURE_REQUEST_TOPICS),
|
|
29
|
+
details: z.string().trim().max(FEATURE_REQUEST_DETAILS_MAX).optional(),
|
|
30
|
+
// Where they were standing when they asked. Same-origin path only, so it cannot carry a URL.
|
|
31
|
+
page: z.string().trim().max(200).optional(),
|
|
32
|
+
});
|
|
33
|
+
export const featureRequestResponseSchema = z.object({
|
|
34
|
+
ok: z.literal(true),
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=featureRequests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"featureRequests.js","sourceRoot":"","sources":["../../src/v1/featureRequests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,KAAK;IACL,WAAW;IACX,SAAS;IACT,MAAM;IACN,UAAU;IACV,OAAO;CACC,CAAA;AAIV,oGAAoG;AACpG,mDAAmD;AACnD,MAAM,CAAC,MAAM,sBAAsB,GAAwC;IACzE,GAAG,EAAE,YAAY;IACjB,SAAS,EAAE,qBAAqB;IAChC,OAAO,EAAE,cAAc;IACvB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,gBAAgB;IAC1B,KAAK,EAAE,OAAO;CACf,CAAA;AAED,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAA;AAE/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IACrC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC,QAAQ,EAAE;IACtE,6FAA6F;IAC7F,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;CACpB,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const healthResponseSchema: z.ZodObject<{
|
|
3
|
+
ok: z.ZodLiteral<true>;
|
|
4
|
+
service: z.ZodLiteral<"cloud-control-plane">;
|
|
5
|
+
version: z.ZodString;
|
|
6
|
+
database: z.ZodEnum<{
|
|
7
|
+
up: "up";
|
|
8
|
+
down: "down";
|
|
9
|
+
unknown: "unknown";
|
|
10
|
+
}>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export type HealthResponse = z.infer<typeof healthResponseSchema>;
|
|
13
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/v1/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,oBAAoB;;;;;;;;;iBAO/B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const healthResponseSchema = z.object({
|
|
3
|
+
ok: z.literal(true),
|
|
4
|
+
service: z.literal('cloud-control-plane'),
|
|
5
|
+
version: z.string(),
|
|
6
|
+
// Reported rather than asserted: a control plane that answers while its database is unreachable
|
|
7
|
+
// is still useful information to a load balancer.
|
|
8
|
+
database: z.enum(['up', 'down', 'unknown']),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=health.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/v1/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;IACnB,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,gGAAgG;IAChG,kDAAkD;IAClD,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;CAC5C,CAAC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './common.js';
|
|
2
|
+
export * from './health.js';
|
|
3
|
+
export * from './workflows.js';
|
|
4
|
+
export * from './uploads.js';
|
|
5
|
+
export * from './runs.js';
|
|
6
|
+
export * from './assets.js';
|
|
7
|
+
export * from './plans.js';
|
|
8
|
+
export * from './me.js';
|
|
9
|
+
export * from './usernames.js';
|
|
10
|
+
export * from './terms.js';
|
|
11
|
+
export * from './apiKeys.js';
|
|
12
|
+
export * from './datasets.js';
|
|
13
|
+
export * from './characters.js';
|
|
14
|
+
export * from './characterListings.js';
|
|
15
|
+
export * from './credits.js';
|
|
16
|
+
export * from './purchases.js';
|
|
17
|
+
export * from './capacity.js';
|
|
18
|
+
export * from './videoPricing.js';
|
|
19
|
+
export * from './studio.js';
|
|
20
|
+
export * from './sessions.js';
|
|
21
|
+
export * from './accessRequests.js';
|
|
22
|
+
export * from './featureRequests.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
package/dist/v1/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export * from './common.js';
|
|
2
|
+
export * from './health.js';
|
|
3
|
+
export * from './workflows.js';
|
|
4
|
+
export * from './uploads.js';
|
|
5
|
+
export * from './runs.js';
|
|
6
|
+
export * from './assets.js';
|
|
7
|
+
export * from './plans.js';
|
|
8
|
+
export * from './me.js';
|
|
9
|
+
export * from './usernames.js';
|
|
10
|
+
export * from './terms.js';
|
|
11
|
+
export * from './apiKeys.js';
|
|
12
|
+
export * from './datasets.js';
|
|
13
|
+
export * from './characters.js';
|
|
14
|
+
export * from './characterListings.js';
|
|
15
|
+
export * from './credits.js';
|
|
16
|
+
export * from './purchases.js';
|
|
17
|
+
export * from './capacity.js';
|
|
18
|
+
export * from './videoPricing.js';
|
|
19
|
+
export * from './studio.js';
|
|
20
|
+
export * from './sessions.js';
|
|
21
|
+
export * from './accessRequests.js';
|
|
22
|
+
export * from './featureRequests.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
package/dist/v1/me.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const meSchema: z.ZodObject<{
|
|
3
|
+
userId: z.ZodUUID;
|
|
4
|
+
email: z.ZodNullable<z.ZodString>;
|
|
5
|
+
name: z.ZodNullable<z.ZodString>;
|
|
6
|
+
avatarUrl: z.ZodNullable<z.ZodURL>;
|
|
7
|
+
joinedAt: z.ZodISODateTime;
|
|
8
|
+
username: z.ZodNullable<z.ZodString>;
|
|
9
|
+
plan: z.ZodObject<{
|
|
10
|
+
id: z.ZodEnum<{
|
|
11
|
+
free: "free";
|
|
12
|
+
}>;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
storageBytes: z.ZodNumber;
|
|
15
|
+
unlimitedCredits: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
role: z.ZodEnum<{
|
|
18
|
+
admin: "admin";
|
|
19
|
+
team: "team";
|
|
20
|
+
member: "member";
|
|
21
|
+
user: "user";
|
|
22
|
+
}>;
|
|
23
|
+
terms: z.ZodObject<{
|
|
24
|
+
version: z.ZodNullable<z.ZodString>;
|
|
25
|
+
acceptedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
26
|
+
previousVersion: z.ZodNullable<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type Me = z.infer<typeof meSchema>;
|
|
30
|
+
//# sourceMappingURL=me.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../src/v1/me.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;iBAenB,CAAA;AAEF,MAAM,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAA"}
|
package/dist/v1/me.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { planSchema } from './plans.js';
|
|
3
|
+
import { termsAcceptanceSchema } from './terms.js';
|
|
4
|
+
// The signed-in person, as this service knows them. Name and picture come from their sign-in
|
|
5
|
+
// provider; both are optional because no provider guarantees either.
|
|
6
|
+
export const meSchema = z.object({
|
|
7
|
+
userId: z.uuid(),
|
|
8
|
+
email: z.string().nullable(),
|
|
9
|
+
name: z.string().nullable(),
|
|
10
|
+
avatarUrl: z.url().nullable(),
|
|
11
|
+
joinedAt: z.iso.datetime(),
|
|
12
|
+
// The public handle their work is credited to, or null until they choose one. Nullable rather than
|
|
13
|
+
// absent because every account that predates handles has none, and nothing is backfilled.
|
|
14
|
+
username: z.string().nullable(),
|
|
15
|
+
plan: planSchema,
|
|
16
|
+
// What this person may do. The browser uses it to decide what to render; the control plane checks
|
|
17
|
+
// it again on every route, because a hidden button is not an authorization control.
|
|
18
|
+
role: z.enum(['admin', 'team', 'member', 'user']),
|
|
19
|
+
// Recorded at sign-in from the verified session. The browser never supplies it.
|
|
20
|
+
terms: termsAcceptanceSchema,
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=me.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"me.js","sourceRoot":"","sources":["../../src/v1/me.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,6FAA6F;AAC7F,qEAAqE;AACrE,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC1B,mGAAmG;IACnG,0FAA0F;IAC1F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,IAAI,EAAE,UAAU;IAChB,kGAAkG;IAClG,oFAAoF;IACpF,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjD,gFAAgF;IAChF,KAAK,EAAE,qBAAqB;CAC7B,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PLAN_IDS: readonly ["free"];
|
|
3
|
+
export declare const planIdSchema: z.ZodEnum<{
|
|
4
|
+
free: "free";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const planSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodEnum<{
|
|
8
|
+
free: "free";
|
|
9
|
+
}>;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
storageBytes: z.ZodNumber;
|
|
12
|
+
unlimitedCredits: z.ZodBoolean;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare const FREE_PLAN: {
|
|
15
|
+
readonly id: "free";
|
|
16
|
+
readonly name: "Free";
|
|
17
|
+
readonly storageBytes: number;
|
|
18
|
+
readonly unlimitedCredits: true;
|
|
19
|
+
};
|
|
20
|
+
export declare const PLANS: {
|
|
21
|
+
readonly free: {
|
|
22
|
+
readonly id: "free";
|
|
23
|
+
readonly name: "Free";
|
|
24
|
+
readonly storageBytes: number;
|
|
25
|
+
readonly unlimitedCredits: true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export type PlanId = z.infer<typeof planIdSchema>;
|
|
29
|
+
export type Plan = z.infer<typeof planSchema>;
|
|
30
|
+
//# sourceMappingURL=plans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plans.d.ts","sourceRoot":"","sources":["../../src/v1/plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,QAAQ,mBAAoB,CAAA;AACzC,eAAO,MAAM,YAAY;;EAAmB,CAAA;AAE5C,eAAO,MAAM,UAAU;;;;;;;iBAMrB,CAAA;AAEF,eAAO,MAAM,SAAS;;;;;CAKyB,CAAA;AAE/C,eAAO,MAAM,KAAK;;;;;;;CAA+B,CAAA;AAEjD,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
package/dist/v1/plans.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// What an account is entitled to. One plan today; the shape exists so a second one is data, not code.
|
|
3
|
+
export const PLAN_IDS = ['free'];
|
|
4
|
+
export const planIdSchema = z.enum(PLAN_IDS);
|
|
5
|
+
export const planSchema = z.object({
|
|
6
|
+
id: planIdSchema,
|
|
7
|
+
name: z.string(),
|
|
8
|
+
storageBytes: z.number().int().positive(),
|
|
9
|
+
// Credits are bought, not granted: there is no ceiling on how many an account may load.
|
|
10
|
+
unlimitedCredits: z.boolean(),
|
|
11
|
+
});
|
|
12
|
+
export const FREE_PLAN = {
|
|
13
|
+
id: 'free',
|
|
14
|
+
name: 'Free',
|
|
15
|
+
storageBytes: 5 * 1024 * 1024 * 1024,
|
|
16
|
+
unlimitedCredits: true,
|
|
17
|
+
};
|
|
18
|
+
export const PLANS = { free: FREE_PLAN };
|
|
19
|
+
//# sourceMappingURL=plans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plans.js","sourceRoot":"","sources":["../../src/v1/plans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,sGAAsG;AACtG,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAU,CAAA;AACzC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IACzC,wFAAwF;IACxF,gBAAgB,EAAE,CAAC,CAAC,OAAO,EAAE;CAC9B,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,EAAE,EAAE,MAAM;IACV,IAAI,EAAE,MAAM;IACZ,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IACpC,gBAAgB,EAAE,IAAI;CACuB,CAAA;AAE/C,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,SAAS,EAAW,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PURCHASE_CURRENCY = "USD";
|
|
3
|
+
export declare const MIN_PURCHASE_CREDITS = 1000;
|
|
4
|
+
export declare const MAX_PURCHASE_CREDITS = 100000;
|
|
5
|
+
export declare const CREDIT_PACKS: readonly [2500, 5000, 10000];
|
|
6
|
+
/** Whole credits for a dollar figure. Rounded, because a third decimal is a fraction of a cent. */
|
|
7
|
+
export declare function creditsForDollars(dollars: number): number;
|
|
8
|
+
export declare function dollarsForCredits(credits: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* What the payment provider is told to charge, in the currency's smallest unit.
|
|
11
|
+
*
|
|
12
|
+
* A credit is one US cent, so this is the credit count itself. Kept as a named function rather than
|
|
13
|
+
* an equality nobody wrote down: if the rate ever moves, the call sites stay right and the test
|
|
14
|
+
* pinning this fails instead of the charge quietly drifting from the grant.
|
|
15
|
+
*/
|
|
16
|
+
export declare function smallestUnitForCredits(credits: number): number;
|
|
17
|
+
export declare const createCreditOrderBodySchema: z.ZodObject<{
|
|
18
|
+
credits: z.ZodNumber;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const createCreditOrderResponseSchema: z.ZodObject<{
|
|
21
|
+
orderId: z.ZodString;
|
|
22
|
+
amount: z.ZodNumber;
|
|
23
|
+
currency: z.ZodLiteral<"USD">;
|
|
24
|
+
credits: z.ZodNumber;
|
|
25
|
+
keyId: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export declare const confirmCreditOrderBodySchema: z.ZodObject<{
|
|
28
|
+
paymentId: z.ZodString;
|
|
29
|
+
signature: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export declare const confirmCreditOrderResponseSchema: z.ZodObject<{
|
|
32
|
+
applied: z.ZodBoolean;
|
|
33
|
+
balance: z.ZodNumber;
|
|
34
|
+
credits: z.ZodNumber;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export type CreateCreditOrderBody = z.infer<typeof createCreditOrderBodySchema>;
|
|
37
|
+
export type CreateCreditOrderResponse = z.infer<typeof createCreditOrderResponseSchema>;
|
|
38
|
+
export type ConfirmCreditOrderBody = z.infer<typeof confirmCreditOrderBodySchema>;
|
|
39
|
+
export type ConfirmCreditOrderResponse = z.infer<typeof confirmCreditOrderResponseSchema>;
|
|
40
|
+
//# sourceMappingURL=purchases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchases.d.ts","sourceRoot":"","sources":["../../src/v1/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAKvB,eAAO,MAAM,iBAAiB,QAAQ,CAAA;AAKtC,eAAO,MAAM,oBAAoB,OAAQ,CAAA;AACzC,eAAO,MAAM,oBAAoB,SAAU,CAAA;AAG3C,eAAO,MAAM,YAAY,8BAAkC,CAAA;AAE3D,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE9D;AAID,eAAO,MAAM,2BAA2B;;iBAEtC,CAAA;AAEF,eAAO,MAAM,+BAA+B;;;;;;iBAU1C,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;iBAK3C,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAC/E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AACvF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACjF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { USD_PER_CREDIT } from './credits.js';
|
|
3
|
+
// Charged in US dollars, and hardcoded rather than taken from a request: INR and USD are both
|
|
4
|
+
// hundredths, so a substituted currency leaves the integer amount identical and changes the money.
|
|
5
|
+
export const PURCHASE_CURRENCY = 'USD';
|
|
6
|
+
// $10 and $1000. Held as credits because that is what the wire carries; dollars are a rendering
|
|
7
|
+
// concern, and `MAX_PURCHASE_CREDITS` must stay under the ledger's own MAX_GRANT_CREDITS or a legal
|
|
8
|
+
// purchase takes the money and then fails to grant it.
|
|
9
|
+
export const MIN_PURCHASE_CREDITS = 1_000;
|
|
10
|
+
export const MAX_PURCHASE_CREDITS = 100_000;
|
|
11
|
+
// $25 / $50 / $100. Offered amounts, not the only ones: anything inside the bounds above is valid.
|
|
12
|
+
export const CREDIT_PACKS = [2_500, 5_000, 10_000];
|
|
13
|
+
/** Whole credits for a dollar figure. Rounded, because a third decimal is a fraction of a cent. */
|
|
14
|
+
export function creditsForDollars(dollars) {
|
|
15
|
+
return Math.round(dollars / USD_PER_CREDIT);
|
|
16
|
+
}
|
|
17
|
+
export function dollarsForCredits(credits) {
|
|
18
|
+
return credits * USD_PER_CREDIT;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* What the payment provider is told to charge, in the currency's smallest unit.
|
|
22
|
+
*
|
|
23
|
+
* A credit is one US cent, so this is the credit count itself. Kept as a named function rather than
|
|
24
|
+
* an equality nobody wrote down: if the rate ever moves, the call sites stay right and the test
|
|
25
|
+
* pinning this fails instead of the charge quietly drifting from the grant.
|
|
26
|
+
*/
|
|
27
|
+
export function smallestUnitForCredits(credits) {
|
|
28
|
+
return Math.round(dollarsForCredits(credits) * 100);
|
|
29
|
+
}
|
|
30
|
+
// The browser sends credits and nothing else. The amount, the currency and the buyer are all
|
|
31
|
+
// decided server-side, so there is no field here worth tampering with.
|
|
32
|
+
export const createCreditOrderBodySchema = z.object({
|
|
33
|
+
credits: z.number().int().min(MIN_PURCHASE_CREDITS).max(MAX_PURCHASE_CREDITS),
|
|
34
|
+
});
|
|
35
|
+
export const createCreditOrderResponseSchema = z.object({
|
|
36
|
+
orderId: z.string().min(1),
|
|
37
|
+
// The smallest unit, exactly as the provider was told it. Echoed so the checkout modal is opened
|
|
38
|
+
// with the server's figure rather than one the browser recomputed.
|
|
39
|
+
amount: z.number().int().positive(),
|
|
40
|
+
currency: z.literal(PURCHASE_CURRENCY),
|
|
41
|
+
credits: z.number().int().positive(),
|
|
42
|
+
// The publishable key id, which is in the provider's own client snippet. Returned with the order
|
|
43
|
+
// so the key and the order cannot come from different accounts or different modes.
|
|
44
|
+
keyId: z.string().min(1),
|
|
45
|
+
});
|
|
46
|
+
export const confirmCreditOrderBodySchema = z.object({
|
|
47
|
+
paymentId: z.string().min(1).max(64),
|
|
48
|
+
signature: z.string().min(1).max(200),
|
|
49
|
+
});
|
|
50
|
+
export const confirmCreditOrderResponseSchema = z.object({
|
|
51
|
+
// False when the credits were already granted, which the webhook usually does first.
|
|
52
|
+
applied: z.boolean(),
|
|
53
|
+
balance: z.number(),
|
|
54
|
+
credits: z.number().int().positive(),
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=purchases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchases.js","sourceRoot":"","sources":["../../src/v1/purchases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAA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