@ebitex/content-sdk 0.21.163 → 0.22.198

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.
Files changed (66) hide show
  1. package/README.md +18 -0
  2. package/dist/apply/args.d.ts +18 -0
  3. package/dist/apply/args.d.ts.map +1 -0
  4. package/dist/apply/args.js +81 -0
  5. package/dist/apply/args.js.map +1 -0
  6. package/dist/apply/blobs.d.ts +19 -0
  7. package/dist/apply/blobs.d.ts.map +1 -0
  8. package/dist/apply/blobs.js +56 -0
  9. package/dist/apply/blobs.js.map +1 -0
  10. package/dist/apply/client.d.ts +66 -0
  11. package/dist/apply/client.d.ts.map +1 -0
  12. package/dist/apply/client.js +98 -0
  13. package/dist/apply/client.js.map +1 -0
  14. package/dist/apply/lockfile.d.ts +12 -0
  15. package/dist/apply/lockfile.d.ts.map +1 -0
  16. package/dist/apply/lockfile.js +25 -0
  17. package/dist/apply/lockfile.js.map +1 -0
  18. package/dist/apply/modelFiles.d.ts +10 -0
  19. package/dist/apply/modelFiles.d.ts.map +1 -0
  20. package/dist/apply/modelFiles.js +88 -0
  21. package/dist/apply/modelFiles.js.map +1 -0
  22. package/dist/apply/run.d.ts +26 -0
  23. package/dist/apply/run.d.ts.map +1 -0
  24. package/dist/apply/run.js +178 -0
  25. package/dist/apply/run.js.map +1 -0
  26. package/dist/audience/client.d.ts +63 -0
  27. package/dist/audience/client.d.ts.map +1 -0
  28. package/dist/audience/client.js +36 -0
  29. package/dist/audience/client.js.map +1 -0
  30. package/dist/cli/apply-main.d.ts +3 -0
  31. package/dist/cli/apply-main.d.ts.map +1 -0
  32. package/dist/cli/apply-main.js +54 -0
  33. package/dist/cli/apply-main.js.map +1 -0
  34. package/dist/delivery/client.d.ts +6 -0
  35. package/dist/delivery/client.d.ts.map +1 -1
  36. package/dist/delivery/client.js +3 -3
  37. package/dist/delivery/client.js.map +1 -1
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +2 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/model/compile.d.ts +28 -0
  43. package/dist/model/compile.d.ts.map +1 -0
  44. package/dist/model/compile.js +384 -0
  45. package/dist/model/compile.js.map +1 -0
  46. package/dist/model/decompile.d.ts +9 -0
  47. package/dist/model/decompile.d.ts.map +1 -0
  48. package/dist/model/decompile.js +231 -0
  49. package/dist/model/decompile.js.map +1 -0
  50. package/dist/model/index.d.ts +7 -0
  51. package/dist/model/index.d.ts.map +1 -0
  52. package/dist/model/index.js +5 -0
  53. package/dist/model/index.js.map +1 -0
  54. package/dist/model/sha256.d.ts +10 -0
  55. package/dist/model/sha256.d.ts.map +1 -0
  56. package/dist/model/sha256.js +81 -0
  57. package/dist/model/sha256.js.map +1 -0
  58. package/dist/model/types.d.ts +170 -0
  59. package/dist/model/types.d.ts.map +1 -0
  60. package/dist/model/types.js +9 -0
  61. package/dist/model/types.js.map +1 -0
  62. package/dist/preview/protocol.d.ts +1 -1
  63. package/dist/preview/protocol.d.ts.map +1 -1
  64. package/dist/types.d.ts +2 -1
  65. package/dist/types.d.ts.map +1 -1
  66. package/package.json +6 -1
package/README.md CHANGED
@@ -93,3 +93,21 @@ Full guide and reference: [developers.ebitex.io](https://developers.ebitex.io/ge
93
93
  Worked examples: the [ebitex samples](https://github.com/ebitex-io/samples) repository has two
94
94
  complete Northwind Coffee sites built on this package, one static and one server-rendered, each
95
95
  with the content model it expects.
96
+
97
+ ## Know the visitor's audiences
98
+
99
+ Personalized content asks for an audience by id. Ask Audience which ones a visitor is in, from your presentation app
100
+ (once when a session starts, again on each route change), then send the ids as `ctx.audiences`:
101
+
102
+ ```ts
103
+ import { createAudienceClient, withAudiences } from '@ebitex/content-sdk'
104
+
105
+ const audience = createAudienceClient({ apiKey: import.meta.env.VITE_AUDIENCE_DELIVERY_KEY })
106
+
107
+ const resolved = await audience.resolve({ ctx: { buyerType }, visitor: visitorToken, consent: { cmp: 'granted' } })
108
+ const context = withAudiences({ buyerType }, resolved)
109
+ ```
110
+
111
+ An Audience delivery key is its own kind (a Content delivery key does not work). One with an allowed-origins list is
112
+ browser-safe and the list is checked on every request. `visitor` and `consent` are optional: without them, or without
113
+ consent granted on that device, the context alone decides and `resolved.reason` says why. Content never calls Audience.
@@ -0,0 +1,18 @@
1
+ export type ApplyCommand = 'plan' | 'apply' | 'pull';
2
+ export interface ApplyArgs {
3
+ command: ApplyCommand;
4
+ baseUrl: string;
5
+ modelPath: string;
6
+ lockPath: string;
7
+ confirmOverwrite: boolean;
8
+ publish: boolean;
9
+ deliveryEnvironmentId?: string;
10
+ help: boolean;
11
+ }
12
+ export declare class ApplyArgsError extends Error {
13
+ constructor(message: string);
14
+ }
15
+ export declare const KEY_VARIABLE = "EBITEX_CONTENT_MANAGEMENT_KEY";
16
+ export declare const USAGE = "usage: EBITEX_CONTENT_MANAGEMENT_KEY=<key> content-sdk-apply <plan|apply|pull> [options]\n\n plan Compile the model and print what would change. Needs only the read scope; writes nothing.\n apply Write what differs. Refuses a conflict unless --confirm-overwrite is given.\n pull Write the environment out as a model directory (into a new, empty directory).\n\noptions:\n --model <path> model directory, .json file or JavaScript module (default ./content-model)\n --lock <path> lockfile of state tokens (default ./content.lock.json)\n --base <url> API origin (default https://api.ebitex.io)\n --confirm-overwrite apply: overwrite items the server reports as conflicts\n --publish apply: publish the nodes and Components this run changed\n --delivery-environment <id> apply --publish: required when the key's environment publishes to several\n\nThe key comes from EBITEX_CONTENT_MANAGEMENT_KEY and is never a flag. It is bound to one authoring environment, so\nchoosing the key chooses the environment.";
17
+ export declare function parseApplyArgs(argv: string[]): ApplyArgs;
18
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../../src/apply/args.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAA;AAEpD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,YAAY,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,OAAO,CAAA;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,IAAI,EAAE,OAAO,CAAA;CACd;AAED,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,YAAY,kCAAkC,CAAA;AAE3D,eAAO,MAAM,KAAK,ynCAewB,CAAA;AAK1C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAkDxD"}
@@ -0,0 +1,81 @@
1
+ export class ApplyArgsError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = 'ApplyArgsError';
5
+ }
6
+ }
7
+ export const KEY_VARIABLE = 'EBITEX_CONTENT_MANAGEMENT_KEY';
8
+ export const USAGE = `usage: ${KEY_VARIABLE}=<key> content-sdk-apply <plan|apply|pull> [options]
9
+
10
+ plan Compile the model and print what would change. Needs only the read scope; writes nothing.
11
+ apply Write what differs. Refuses a conflict unless --confirm-overwrite is given.
12
+ pull Write the environment out as a model directory (into a new, empty directory).
13
+
14
+ options:
15
+ --model <path> model directory, .json file or JavaScript module (default ./content-model)
16
+ --lock <path> lockfile of state tokens (default ./content.lock.json)
17
+ --base <url> API origin (default https://api.ebitex.io)
18
+ --confirm-overwrite apply: overwrite items the server reports as conflicts
19
+ --publish apply: publish the nodes and Components this run changed
20
+ --delivery-environment <id> apply --publish: required when the key's environment publishes to several
21
+
22
+ The key comes from ${KEY_VARIABLE} and is never a flag. It is bound to one authoring environment, so
23
+ choosing the key chooses the environment.`;
24
+ const VALUE_FLAGS = new Set(['model', 'lock', 'base', 'delivery-environment']);
25
+ const BOOLEAN_FLAGS = new Set(['confirm-overwrite', 'publish', 'help']);
26
+ export function parseApplyArgs(argv) {
27
+ const values = {};
28
+ const flags = new Set();
29
+ const positional = [];
30
+ for (let i = 0; i < argv.length; i++) {
31
+ const arg = argv[i];
32
+ if (!arg.startsWith('--')) {
33
+ positional.push(arg);
34
+ continue;
35
+ }
36
+ const name = arg.slice(2);
37
+ if (name === 'key' || name.startsWith('key=') || name === 'key-file') {
38
+ throw new ApplyArgsError(`There is no --key flag: a flag lands the credential in shell history and CI logs. Set ${KEY_VARIABLE} instead.`);
39
+ }
40
+ if (BOOLEAN_FLAGS.has(name)) {
41
+ flags.add(name);
42
+ }
43
+ else if (VALUE_FLAGS.has(name)) {
44
+ const next = argv[i + 1];
45
+ if (next === undefined || next.startsWith('--'))
46
+ throw new ApplyArgsError(`--${name} needs a value.`);
47
+ values[name] = next;
48
+ i++;
49
+ }
50
+ else if (name === 'environment' || name === 'env') {
51
+ throw new ApplyArgsError('There is no environment argument: the key is bound to one environment, so choosing the key chooses it.');
52
+ }
53
+ else {
54
+ throw new ApplyArgsError(`Unknown option --${name}.`);
55
+ }
56
+ }
57
+ const help = flags.has('help');
58
+ const command = positional[0];
59
+ if (!help && positional.length === 0)
60
+ throw new ApplyArgsError(`A command is required.
61
+
62
+ ${USAGE}`);
63
+ if (!help && command !== 'plan' && command !== 'apply' && command !== 'pull') {
64
+ throw new ApplyArgsError(`Unknown command "${command}". Expected plan, apply or pull.`);
65
+ }
66
+ if (flags.has('confirm-overwrite') && command !== 'apply')
67
+ throw new ApplyArgsError('--confirm-overwrite only applies to `apply`.');
68
+ if (flags.has('publish') && command !== 'apply')
69
+ throw new ApplyArgsError('--publish only applies to `apply`.');
70
+ return {
71
+ command: (help ? 'plan' : command),
72
+ baseUrl: values.base ?? 'https://api.ebitex.io',
73
+ modelPath: values.model ?? './content-model',
74
+ lockPath: values.lock ?? './content.lock.json',
75
+ confirmOverwrite: flags.has('confirm-overwrite'),
76
+ publish: flags.has('publish'),
77
+ ...(values['delivery-environment'] ? { deliveryEnvironmentId: values['delivery-environment'] } : {}),
78
+ help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I,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO,KAAK,OAAO;QAAE,MAAM,IAAI,cAAc,CAAC,8CAA8C,CAAC,CAAA;IACnI,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,OAAO,KAAK,OAAO;QAAE,MAAM,IAAI,cAAc,CAAC,oCAAoC,CAAC,CAAA;IAE/G,OAAO;QACL,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAiB;QAClD,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,uBAAuB;QAC/C,SAAS,EAAE,MAAM,CAAC,KAAK,IAAI,iBAAiB;QAC5C,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,qBAAqB;QAC9C,gBAAgB,EAAE,KAAK,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAChD,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC;QAC7B,GAAG,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,MAAM,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,IAAI;KACL,CAAA;AACH,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { BlobDescriptor, FileRef } from '../model/index.js';
2
+ import type { ManagementClient } from './client.js';
3
+ export interface BlobResolution {
4
+ /** Descriptors for every file, keyed by the path the model wrote. */
5
+ descriptors: Map<string, BlobDescriptor>;
6
+ /** Files the target does not hold. Under a dry run these are reported, never uploaded. */
7
+ pending: string[];
8
+ }
9
+ /** The marker used for a file a dry run did not upload; inert on the plan path and loud on any write. */
10
+ export declare const PENDING_BLOB_PREFIX = "ebitex-pending-blob:";
11
+ /**
12
+ * Hash each file, ask the server which bytes it holds, and upload only the rest, so a converged model
13
+ * plans with a read-only key and costs one read. A dry run never uploads: it substitutes a marker that
14
+ * could not be mistaken for a real blob id.
15
+ */
16
+ export declare function resolveFiles(refs: FileRef[], baseDir: string, client: ManagementClient, options: {
17
+ dryRun: boolean;
18
+ }): Promise<BlobResolution>;
19
+ //# sourceMappingURL=blobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blobs.d.ts","sourceRoot":"","sources":["../../src/apply/blobs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAgBnD,MAAM,WAAW,cAAc;IAC7B,qEAAqE;IACrE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACxC,0FAA0F;IAC1F,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,yGAAyG;AACzG,eAAO,MAAM,mBAAmB,yBAAyB,CAAA;AAEzD;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,OAAO,EAAE,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,GAC3B,OAAO,CAAC,cAAc,CAAC,CA+BzB"}
@@ -0,0 +1,56 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFileSync } from 'node:fs';
3
+ import { extname, resolve } from 'node:path';
4
+ const TYPES = {
5
+ '.png': 'image/png',
6
+ '.jpg': 'image/jpeg',
7
+ '.jpeg': 'image/jpeg',
8
+ '.gif': 'image/gif',
9
+ '.webp': 'image/webp',
10
+ '.svg': 'image/svg+xml',
11
+ '.avif': 'image/avif',
12
+ '.pdf': 'application/pdf',
13
+ '.mp4': 'video/mp4',
14
+ '.json': 'application/json',
15
+ '.txt': 'text/plain',
16
+ };
17
+ /** The marker used for a file a dry run did not upload; inert on the plan path and loud on any write. */
18
+ export const PENDING_BLOB_PREFIX = 'ebitex-pending-blob:';
19
+ /**
20
+ * Hash each file, ask the server which bytes it holds, and upload only the rest, so a converged model
21
+ * plans with a read-only key and costs one read. A dry run never uploads: it substitutes a marker that
22
+ * could not be mistaken for a real blob id.
23
+ */
24
+ export async function resolveFiles(refs, baseDir, client, options) {
25
+ const bytesByPath = new Map();
26
+ for (const ref of refs) {
27
+ const bytes = readFileSync(resolve(baseDir, ref.$file));
28
+ bytesByPath.set(ref.$file, {
29
+ bytes,
30
+ hash: createHash('sha256').update(bytes).digest('hex'),
31
+ contentType: ref.contentType ?? TYPES[extname(ref.$file).toLowerCase()] ?? 'application/octet-stream',
32
+ });
33
+ }
34
+ const held = await client.resolveBlobs([...bytesByPath.values()].map((b) => b.hash));
35
+ const descriptors = new Map();
36
+ const pending = [];
37
+ for (const [path, file] of bytesByPath) {
38
+ const existing = held.get(file.hash);
39
+ if (existing) {
40
+ descriptors.set(path, existing);
41
+ }
42
+ else if (options.dryRun) {
43
+ pending.push(path);
44
+ descriptors.set(path, {
45
+ blobId: `${PENDING_BLOB_PREFIX}${file.hash}`,
46
+ contentType: file.contentType,
47
+ sizeBytes: file.bytes.length,
48
+ });
49
+ }
50
+ else {
51
+ descriptors.set(path, await client.uploadBlob(file.bytes, file.contentType));
52
+ }
53
+ }
54
+ return { descriptors, pending };
55
+ }
56
+ //# sourceMappingURL=blobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blobs.js","sourceRoot":"","sources":["../../src/apply/blobs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAI5C,MAAM,KAAK,GAA2B;IACpC,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,YAAY;IACpB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,MAAM,EAAE,eAAe;IACvB,OAAO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A;QACpC,IAAI,QAAQ,EAAE,CAAC;YACb,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QACjC,CAAC;aAAM,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAClB,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE;gBACpB,MAAM,EAAE,GAAG,mBAAmB,GAAG,IAAI,CAAC,IAAI,EAAE;gBAC5C,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;aAC7B,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;QAC9E,CAAC;IACH,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAA;AACjC,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { BlobDescriptor, BundleDocument } from '../model/index.js';
2
+ export type PlanState = 'new' | 'update' | 'identical' | 'conflict';
3
+ export interface PlanItem {
4
+ kind: string;
5
+ id: string;
6
+ name?: string | null;
7
+ externalId?: string | null;
8
+ naturalKey?: string | null;
9
+ state: PlanState;
10
+ stateToken?: string | null;
11
+ }
12
+ export interface ImportPlan {
13
+ items: PlanItem[];
14
+ warnings?: string[];
15
+ blockers?: string[];
16
+ }
17
+ export interface ImportResultItem {
18
+ kind: string;
19
+ id: string;
20
+ imported: boolean;
21
+ error?: string | null;
22
+ }
23
+ export interface ImportSelection {
24
+ kind: string;
25
+ id: string;
26
+ confirmOverwrite?: true;
27
+ }
28
+ export interface InventoryItem {
29
+ kind: string;
30
+ id: string;
31
+ naturalKey: string;
32
+ }
33
+ /** The slice of `/content/management/v1` this tool uses. Tests fake it; `createManagementClient` is the real one. */
34
+ export interface ManagementClient {
35
+ exportEverything(): Promise<BundleDocument>;
36
+ importPlan(bundle: BundleDocument, baseTokens: Record<string, string>): Promise<ImportPlan>;
37
+ importBundle(bundle: BundleDocument, items: ImportSelection[], baseTokens: Record<string, string>): Promise<{
38
+ items: ImportResultItem[];
39
+ }>;
40
+ /** Every item the environment holds, paged to the end. */
41
+ inventory(): Promise<InventoryItem[]>;
42
+ resolveBlobs(hashes: string[]): Promise<Map<string, BlobDescriptor>>;
43
+ uploadBlob(bytes: Uint8Array, contentType: string): Promise<BlobDescriptor>;
44
+ publishPlan(roots: Array<{
45
+ kind: string;
46
+ id: string;
47
+ }>, deliveryEnvironmentId?: string): Promise<unknown>;
48
+ publish(items: unknown[], deliveryEnvironmentId?: string): Promise<unknown>;
49
+ }
50
+ export declare class ManagementApiError extends Error {
51
+ readonly status: number;
52
+ readonly body: unknown;
53
+ readonly code: string | undefined;
54
+ constructor(method: string, path: string, status: number, body: unknown);
55
+ }
56
+ export interface ClientOptions {
57
+ /** The API origin, e.g. `https://api.ebitex.io`. */
58
+ baseUrl: string;
59
+ /** A management key. Read from the environment by the caller, never from a flag. */
60
+ key: string;
61
+ fetch?: typeof fetch;
62
+ /** Milliseconds to sleep between operation polls; overridable so tests do not wait. */
63
+ pollDelay?: (attempt: number) => number;
64
+ }
65
+ export declare function createManagementClient(options: ClientOptions): ManagementClient;
66
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/apply/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAA;AAEnE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,GAAG,IA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AE,CAAC,CAAA;IACrC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;IACpE,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAC3E,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IACzG,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,qBAAqB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC5E;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;gBAErB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CASxE;AAED,MAAM,WAAW,aAAa;IAC5B,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,oFAAoF;IACpF,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,uFAAuF;IACvF,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;CACxC;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,gBAAgB,CAsG/E"}
@@ -0,0 +1,98 @@
1
+ export class ManagementApiError extends Error {
2
+ status;
3
+ body;
4
+ code;
5
+ constructor(method, path, status, body) {
6
+ const code = body && typeof body === 'object' ? body.error : undefined;
7
+ const detail = body ? (typeof body === 'string' ? body : JSON.stringify(body)) : '';
8
+ super(`${method} ${path} → ${status}${code ? ` ${code}` : ''}${detail ? `: ${detail}` : ''}`);
9
+ this.name = 'ManagementApiError';
10
+ this.status = status;
11
+ this.body = body;
12
+ this.code = code;
13
+ }
14
+ }
15
+ export function createManagementClient(options) {
16
+ const base = `${options.baseUrl.replace(/\/+$/, '')}/content/management/v1`;
17
+ const doFetch = options.fetch ?? fetch;
18
+ const pollDelay = options.pollDelay ?? ((attempt) => (attempt < 10 ? 500 : 2000));
19
+ async function request(method, path, init = {}) {
20
+ const headers = { Authorization: `Bearer ${options.key}`, Accept: 'application/json' };
21
+ if (init.body !== undefined)
22
+ headers['Content-Type'] = init.contentType ?? 'application/json';
23
+ const response = await doFetch(base + path, {
24
+ method,
25
+ headers,
26
+ body: init.body === undefined ? undefined : init.raw ? init.body : JSON.stringify(init.body),
27
+ });
28
+ if (response.status === 204)
29
+ return undefined;
30
+ const text = await response.text();
31
+ let parsed;
32
+ try {
33
+ parsed = text ? JSON.parse(text) : undefined;
34
+ }
35
+ catch {
36
+ parsed = text;
37
+ }
38
+ if (!response.ok) {
39
+ // A misspelled request property is a 400 that names it; surface the name.
40
+ const property = parsed && typeof parsed === 'object' && parsed.error === 'unknown_property'
41
+ ? parsed.property
42
+ : undefined;
43
+ throw new ManagementApiError(method, property ? `${path} (unknown property: ${property})` : path, response.status, parsed);
44
+ }
45
+ return parsed;
46
+ }
47
+ /** Import and publish are jobs: a 202 with an id, polled until it finishes. */
48
+ async function runOperation(path, body) {
49
+ const kickoff = await request('POST', path, { body });
50
+ for (let attempt = 0;; attempt++) {
51
+ if (attempt > 300) {
52
+ throw new ManagementApiError('POST', path, 202, `operation ${kickoff.id} did not finish after ${attempt} polls`);
53
+ }
54
+ await new Promise((resolve) => setTimeout(resolve, pollDelay(attempt)));
55
+ const run = await request('GET', `/operations/${kickoff.id}`);
56
+ if (run.status === 'succeeded')
57
+ return run.result;
58
+ if (run.status === 'failed') {
59
+ throw new ManagementApiError('POST', path, 202, run.error ?? `operation ${kickoff.id} failed`);
60
+ }
61
+ }
62
+ }
63
+ return {
64
+ exportEverything: () => request('POST', '/export', { body: { wholeEnvironment: true } }),
65
+ importPlan: (bundle, baseTokens) => request('POST', '/import-plan', { body: { bundle, identityMode: 'externalId', baseTokens } }),
66
+ importBundle: (bundle, items, baseTokens) => runOperation('/import', { bundle, identityMode: 'externalId', items, baseTokens }),
67
+ async inventory() {
68
+ const all = [];
69
+ let cursor = null;
70
+ do {
71
+ const page = await request('GET', `/items?limit=200${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
72
+ all.push(...(page.items ?? []));
73
+ cursor = page.nextCursor ?? null;
74
+ } while (cursor);
75
+ return all;
76
+ },
77
+ async resolveBlobs(hashes) {
78
+ const found = new Map();
79
+ const wanted = [...new Set(hashes)];
80
+ // Chunked well under the server's per-request cap on the IN list.
81
+ for (let i = 0; i < wanted.length; i += 50) {
82
+ const query = wanted
83
+ .slice(i, i + 50)
84
+ .map((h) => `hash=${encodeURIComponent(h)}`)
85
+ .join('&');
86
+ const payload = await request('GET', `/blobs?${query}`);
87
+ for (const blob of payload?.blobs ?? []) {
88
+ found.set(blob.hash, { blobId: blob.blobId, contentType: blob.contentType, sizeBytes: blob.sizeBytes });
89
+ }
90
+ }
91
+ return found;
92
+ },
93
+ uploadBlob: (bytes, contentType) => request('POST', '/blobs', { body: bytes, contentType, raw: true }),
94
+ publishPlan: (roots, deliveryEnvironmentId) => runOperation('/publish-plan', { roots, ...(deliveryEnvironmentId ? { deliveryEnvironmentId } : {}) }),
95
+ publish: (items, deliveryEnvironmentId) => runOperation('/publish', { items, ...(deliveryEnvironmentId ? { deliveryEnvironmentId } : {}) }),
96
+ };
97
+ }
98
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/apply/client.ts"],"names":[],"mappings":"AAwDA,MAAM,OAAO,kBA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: 1;
3
+ /** Plan item `naturalKey` to the server-issued `stateToken` of the state this tool last converged. */
4
+ tokens: Record<string, string>;
5
+ }
6
+ export declare const LOCKFILE_NAME = "content.lock.json";
7
+ export declare function emptyLock(): Lockfile;
8
+ export declare function readLock(path: string): Lockfile;
9
+ /** Keys sorted and LF line endings, so the file reviews as a clean diff on any platform. */
10
+ export declare function serializeLock(lock: Lockfile): string;
11
+ export declare function writeLock(path: string, lock: Lockfile): void;
12
+ //# sourceMappingURL=lockfile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lockfile.d.ts","sourceRoot":"","sources":["../../src/apply/lockfile.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,CAAC,CAAA;IACV,sGAAsG;IACtG,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC/B;AAED,eAAO,MAAM,aAAa,sBAAsB,CAAA;AAEhD,wBAAgB,SAAS,IAAI,QAAQ,CAEpC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAO/C;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAGpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAG5D"}
@@ -0,0 +1,25 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
3
+ export const LOCKFILE_NAME = 'content.lock.json';
4
+ export function emptyLock() {
5
+ return { version: 1, tokens: {} };
6
+ }
7
+ export function readLock(path) {
8
+ if (!existsSync(path))
9
+ return emptyLock();
10
+ const parsed = JSON.parse(readFileSync(path, 'utf8'));
11
+ if (parsed.version !== undefined && parsed.version !== 1) {
12
+ throw new Error(`${path}: unsupported lockfile version ${String(parsed.version)}.`);
13
+ }
14
+ return { version: 1, tokens: { ...parsed.tokens } };
15
+ }
16
+ /** Keys sorted and LF line endings, so the file reviews as a clean diff on any platform. */
17
+ export function serializeLock(lock) {
18
+ const tokens = Object.fromEntries(Object.entries(lock.tokens).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
19
+ return `${JSON.stringify({ version: 1, tokens }, null, 2)}\n`;
20
+ }
21
+ export function writeLock(path, lock) {
22
+ mkdirSync(dirname(path), { recursive: true });
23
+ writeFileSync(path, serializeLock(lock), 'utf8');
24
+ }
25
+ //# sourceMappingURL=lockfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lockfile.js","sourceRoot":"","sources":["../../src/apply/lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAA;AAEhD,MAAM,UAAU,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;AACnC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,EAAE,CAAA;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAsB,CAAA;IAC1E,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,kCAAkC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACrF,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,CAAA;AACrD,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,aAAa,CAAC,IAAc;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/G,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAA;AAC/D,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,IAAc;IACpD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7C,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { ContentModel } from '../model/index.js';
2
+ /** Writes one JSON file per entity under `<dir>/<kind>/`. LF endings, so it diffs the same on every OS. */
3
+ export declare function writeModelDirectory(model: ContentModel, dir: string): number;
4
+ /**
5
+ * A model is a directory of JSON (what `pull` writes), a single `.json` file holding a whole model,
6
+ * or a JavaScript module whose default export is one (`defineModel(...)`). TypeScript works wherever
7
+ * the running Node strips types.
8
+ */
9
+ export declare function loadModel(path: string): Promise<ContentModel>;
10
+ //# sourceMappingURL=modelFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelFiles.d.ts","sourceRoot":"","sources":["../../src/apply/modelFiles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAmCrD,2GAA2G;AAC3G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAiB5E;AAMD;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAwBnE"}
@@ -0,0 +1,88 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
+ import { extname, join, resolve } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ const KINDS = [
5
+ 'contracts',
6
+ 'templates',
7
+ 'adapters',
8
+ 'streams',
9
+ 'categoryGroups',
10
+ 'categories',
11
+ 'folders',
12
+ 'components',
13
+ 'nodes',
14
+ ];
15
+ /** What identifies an entity, used only to name its file. */
16
+ function keyOf(kind, entity) {
17
+ switch (kind) {
18
+ case 'categories':
19
+ return `${String(entity.group)}-${String(entity.key)}`;
20
+ case 'folders':
21
+ return String(entity.path);
22
+ case 'nodes':
23
+ return String(entity.key);
24
+ default:
25
+ return String(entity.externalId);
26
+ }
27
+ }
28
+ /** A file name that is safe on every platform and stable for a given key. */
29
+ function fileStem(key) {
30
+ return key.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'item';
31
+ }
32
+ const stringify = (value) => `${JSON.stringify(value, null, 2)}\n`;
33
+ /** Writes one JSON file per entity under `<dir>/<kind>/`. LF endings, so it diffs the same on every OS. */
34
+ export function writeModelDirectory(model, dir) {
35
+ let written = 0;
36
+ for (const kind of KINDS) {
37
+ const entities = (model[kind] ?? []);
38
+ if (entities.length === 0)
39
+ continue;
40
+ const kindDir = join(dir, kind);
41
+ mkdirSync(kindDir, { recursive: true });
42
+ const used = new Set();
43
+ for (const entity of entities) {
44
+ let stem = fileStem(keyOf(kind, entity));
45
+ for (let n = 2; used.has(stem.toLowerCase()); n++)
46
+ stem = `${fileStem(keyOf(kind, entity))}-${n}`;
47
+ used.add(stem.toLowerCase());
48
+ writeFileSync(join(kindDir, `${stem}.json`), stringify(entity), 'utf8');
49
+ written++;
50
+ }
51
+ }
52
+ return written;
53
+ }
54
+ function readJson(path) {
55
+ return JSON.parse(readFileSync(path, 'utf8'));
56
+ }
57
+ /**
58
+ * A model is a directory of JSON (what `pull` writes), a single `.json` file holding a whole model,
59
+ * or a JavaScript module whose default export is one (`defineModel(...)`). TypeScript works wherever
60
+ * the running Node strips types.
61
+ */
62
+ export async function loadModel(path) {
63
+ const full = resolve(path);
64
+ if (!existsSync(full))
65
+ throw new Error(`No model at ${path}.`);
66
+ if (statSync(full).isDirectory()) {
67
+ const model = {};
68
+ for (const kind of KINDS) {
69
+ const kindDir = join(full, kind);
70
+ if (!existsSync(kindDir))
71
+ continue;
72
+ const entities = [];
73
+ for (const name of readdirSync(kindDir).filter((n) => n.endsWith('.json')).sort()) {
74
+ const content = readJson(join(kindDir, name));
75
+ entities.push(...(Array.isArray(content) ? content : [content]));
76
+ }
77
+ model[kind] = entities;
78
+ }
79
+ return model;
80
+ }
81
+ if (extname(full) === '.json')
82
+ return readJson(full);
83
+ const loaded = (await import(pathToFileURL(full).href));
84
+ if (!loaded.default)
85
+ throw new Error(`${path} has no default export. Use "export default defineModel({ … })".`);
86
+ return loaded.default;
87
+ }
88
+ //# sourceMappingURL=modelFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelFiles.js","sourceRoot":"","sources":["../../src/apply/modelFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACnG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAGxC,MAAM,KAAK,GAAG;IACZ,WAAW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C;YACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAChC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAAE,SAAQ;YAClC,MAAM,QAAQ,GAAc,EAAE,CAAA;YAC9B,KAAK,MAAM,IAAI,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBAClF,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;gBAC7C,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;YAClE,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAA;QACxB,CAAC;QACD,OAAO,KAAqB,CAAA;IAC9B,CAAC;IAED,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,QAAQ,CAAC,IAAI,CAAiB,CAAA;IAEpE,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAA+B,CAAA;IACrF,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,kEAAkE,CAAC,CAAA;IAC/G,OAAO,MAAM,CAAC,OAAO,CAAA;AACvB,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { ImportPlan, ManagementClient } from './client.js';
2
+ export interface RunOptions {
3
+ client: ManagementClient;
4
+ /** A model directory, a `.json` model, or a JavaScript module. */
5
+ modelPath: string;
6
+ lockPath: string;
7
+ log?: (line: string) => void;
8
+ }
9
+ export interface ApplyOptions extends RunOptions {
10
+ confirmOverwrite?: boolean;
11
+ publish?: boolean;
12
+ deliveryEnvironmentId?: string;
13
+ }
14
+ export interface PlanResult {
15
+ /** 0 on success; 1 when the plan carries blockers, the model is invalid, or `apply` refused. */
16
+ exitCode: number;
17
+ plan?: ImportPlan;
18
+ /** Lockfile entries the model no longer declares, that the environment still holds. */
19
+ orphans: string[];
20
+ }
21
+ /** Compiles the model and prints the server's own per-item diff. Needs only the read scope and writes nothing. */
22
+ export declare function runPlan(options: RunOptions): Promise<PlanResult>;
23
+ export declare function runApply(options: ApplyOptions): Promise<PlanResult>;
24
+ /** Writes the environment out as a model directory and records its tokens, so it can be adopted. */
25
+ export declare function runPull(options: RunOptions): Promise<PlanResult>;
26
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/apply/run.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAmB,gBAAgB,EAAY,MAAM,aAAa,CAAA;AAI1F,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,gBAAgB,CAAA;IACxB,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7B;AAED,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,UAAU,CAAA;IACjB,uFAAuF;IACvF,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AA0DD,kHAAkH;AAClH,wBAAsB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAYtE;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAyDzE;AA0BD,oGAAoG;AACpG,wBAAsB,OAAO,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAwBtE"}