@notambourine/metafields 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +128 -73
  2. package/dist/admin-shapes.d.ts +57 -0
  3. package/dist/admin-shapes.d.ts.map +1 -0
  4. package/dist/admin-shapes.js +67 -0
  5. package/dist/admin-shapes.js.map +1 -0
  6. package/dist/admin.d.ts +8 -3
  7. package/dist/admin.d.ts.map +1 -1
  8. package/dist/admin.js +187 -102
  9. package/dist/admin.js.map +1 -1
  10. package/dist/app-config.d.ts +5 -0
  11. package/dist/app-config.d.ts.map +1 -0
  12. package/dist/app-config.js +50 -0
  13. package/dist/app-config.js.map +1 -0
  14. package/dist/builders.js +2 -2
  15. package/dist/builders.js.map +1 -1
  16. package/dist/changes.d.ts +20 -0
  17. package/dist/changes.d.ts.map +1 -0
  18. package/dist/changes.js +85 -0
  19. package/dist/changes.js.map +1 -0
  20. package/dist/cli.js +156 -73
  21. package/dist/cli.js.map +1 -1
  22. package/dist/doctor.d.ts +16 -0
  23. package/dist/doctor.d.ts.map +1 -0
  24. package/dist/doctor.js +61 -0
  25. package/dist/doctor.js.map +1 -0
  26. package/dist/fleet.d.ts +10 -3
  27. package/dist/fleet.d.ts.map +1 -1
  28. package/dist/fleet.js +20 -11
  29. package/dist/fleet.js.map +1 -1
  30. package/dist/generator.js +1 -1
  31. package/dist/generator.js.map +1 -1
  32. package/dist/index.d.ts +13 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +6 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/liquid.d.ts.map +1 -1
  37. package/dist/liquid.js +4 -19
  38. package/dist/liquid.js.map +1 -1
  39. package/dist/metafield-types.d.ts +601 -0
  40. package/dist/metafield-types.d.ts.map +1 -0
  41. package/dist/metafield-types.js +150 -0
  42. package/dist/metafield-types.js.map +1 -0
  43. package/dist/migration.d.ts +3 -2
  44. package/dist/migration.d.ts.map +1 -1
  45. package/dist/migration.js +4 -6
  46. package/dist/migration.js.map +1 -1
  47. package/dist/planner.d.ts +4 -2
  48. package/dist/planner.d.ts.map +1 -1
  49. package/dist/planner.js +10 -3
  50. package/dist/planner.js.map +1 -1
  51. package/dist/pull.d.ts.map +1 -1
  52. package/dist/pull.js +3 -62
  53. package/dist/pull.js.map +1 -1
  54. package/dist/schema.d.ts.map +1 -1
  55. package/dist/schema.js +1 -0
  56. package/dist/schema.js.map +1 -1
  57. package/dist/type-check.d.ts +14 -0
  58. package/dist/type-check.d.ts.map +1 -0
  59. package/dist/type-check.js +61 -0
  60. package/dist/type-check.js.map +1 -0
  61. package/dist/type-registry.d.ts +21 -0
  62. package/dist/type-registry.d.ts.map +1 -0
  63. package/dist/type-registry.js +48 -0
  64. package/dist/type-registry.js.map +1 -0
  65. package/package.json +3 -2
package/README.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # @notambourine/metafields
2
2
 
3
- Declare merchant-owned Shopify metafield and metaobject definitions in TypeScript, inspect drift,
4
- and create only what is missing. The CLI never updates or deletes definitions during schema sync.
3
+ Declare Shopify metafield and metaobject definitions in TypeScript, inspect store drift, and apply
4
+ controlled changes. The CLI never deletes or retypes a definition.
5
+
6
+ Requires Node.js 22.18 or newer.
7
+
8
+ ## Quick start
9
+
10
+ Create `schema.ts`:
5
11
 
6
12
  ```ts
7
13
  import { defineSchema, field, metaobject } from '@notambourine/metafields';
@@ -28,112 +34,142 @@ export default defineSchema({
28
34
  });
29
35
  ```
30
36
 
37
+ Validate it, inspect a store, then apply the plan:
38
+
31
39
  ```sh
32
40
  npx @notambourine/metafields ./schema.ts --validate
33
41
  npx @notambourine/metafields ./schema.ts --store example.myshopify.com
34
42
  npx @notambourine/metafields ./schema.ts --store example.myshopify.com --apply
35
- npx @notambourine/metafields ./schema.ts --store example.myshopify.com --check
36
43
  ```
37
44
 
38
- The default command is a dry run. Importing a TypeScript schema executes trusted local code, so
39
- compile declarations to canonical JSON before a secret-bearing workflow consumes pull-request
40
- output.
41
-
42
- Schema modules use Node's built-in type stripping and must use erasable TypeScript syntax.
45
+ Schema modules run as trusted local code through Node's type stripping. Use erasable TypeScript
46
+ syntax. Compile untrusted pull-request declarations before a credentialed workflow consumes them:
43
47
 
44
- See `metafields --help` for `pull`, `compile`, `emit`, and migration commands.
48
+ ```sh
49
+ npx @notambourine/metafields compile ./schema.ts --out ./schema.json
50
+ ```
45
51
 
46
- ## Auth
52
+ Every command accepts `--json` and answers with a single JSON object on stdout, carrying the
53
+ identities it left out under `excluded` or `skipped`. Without `--json`, the document goes to
54
+ stdout and those identities to stderr, so stdout stays pipeable. Writing to `--out` reports
55
+ `{"status":"written","out":"..."}` instead of the document.
47
56
 
48
- Set `SHOPIFY_APP_CLIENT_ID` (or pass `--client-id`) and `SHOPIFY_APP_SECRET`, and the CLI mints a
49
- short-lived Admin token per store with the `client_credentials` grant. Two grant errors stay
50
- distinct in the output because a fleet treats them differently: `app_not_installed` means the store
51
- has not installed the app, `shop_not_permitted` means the app and the store are in different
52
- organizations.
57
+ ## Changes and safety
53
58
 
54
- `SHOPIFY_ADMIN_ACCESS_TOKEN` still works and reaches one store; app auth is an option, not a
55
- requirement. Complete app credentials win when both are set, and half-set ones fall back to the
56
- token rather than failing. Only a fleet, which one token cannot reach, requires the app.
59
+ Without `--apply`, the CLI only reports drift. A definition is updated as one unit: if any part is
60
+ blocked or needs `--force`, its other changes wait too. Other definitions continue independently.
57
61
 
58
- Minted tokens are never logged, and Shopify credential prefixes are redacted from errors.
62
+ | Change | Required mode |
63
+ | --- | --- |
64
+ | Create a definition or add a metaobject field | `--apply` |
65
+ | Update labels, `displayNameKey`, or enable a capability | `--apply` |
66
+ | Change access, validations, constraints, or `required` | `--apply --force` |
67
+ | Disable a capability | `--apply --force` |
68
+ | Delete or retype a definition | Never performed |
69
+ | Change invalid values or a definition Shopify is still validating | Never performed |
59
70
 
60
- ## Fleets
71
+ `--force` opts into changes that can break a storefront or strand stored values. For schema sync it
72
+ requires `--apply`; it cannot override Shopify constraints or repair data.
61
73
 
62
- `--store` repeats, and `--stores-from <file>` sweeps a list of stores, one per line, with `#`
63
- comments:
74
+ Use `--dry-run` to cancel requested writes while preserving the plan and exit code:
64
75
 
65
76
  ```sh
66
- metafields ./schema.ts --store flagship.myshopify.com --stores-from ./stores.txt --apply
77
+ npx @notambourine/metafields ./schema.ts \
78
+ --store example.myshopify.com --apply --force --dry-run
67
79
  ```
68
80
 
69
- - Every store is planned before any store is written to. A conflict on one store exits nonzero
70
- having written nothing, because creating on the others first half-applies the fleet.
71
- - A swept store that cannot be reached is reported and does not abort the run, as long as one store
72
- could be planned. A swept store that has not installed the app is reported as `NOT-INSTALLED` and
73
- keeps the run green.
74
- - A store named on the command line never fails quietly; only a swept store is downgraded.
75
- - Writes run per store, so one store refusing does not stop the next, and every refusal is
76
- reported together.
77
- - Exit is `2` if any store was unreachable or refused a write, even when every reached store came
78
- back clean.
81
+ Exit codes describe the result:
79
82
 
80
- ## Types
83
+ - `0`: the store matches the schema.
84
+ - `1`: actionable drift remains.
85
+ - `2`: input is invalid, Shopify state is indeterminate, or an operation failed.
81
86
 
82
- The schema is the single declaration. Value types come back out of it with `InferMetafields` and
83
- `InferMetaobjects`, and fields declared `required: true` are not optional in the inferred type:
87
+ Cosmetic label drift does not change the exit code. Mutations retry Shopify's explicit
88
+ `THROTTLED` response, but are not retried after a timeout or `5xx` because the first request may
89
+ have landed.
84
90
 
85
- ```ts
86
- type Product = InferMetafields<typeof schema>['product'];
91
+ ## Authentication
92
+
93
+ For one store, set an Admin API token:
87
94
 
88
- const promo: string | undefined = product.custom.promo_text;
89
- const sku: string = product.custom.sku; // declared required
95
+ ```sh
96
+ export SHOPIFY_ADMIN_ACCESS_TOKEN=...
90
97
  ```
91
98
 
92
- ## Liquid
99
+ For one store or a fleet, set app credentials. The CLI mints a short-lived token for each store:
93
100
 
94
- `emit --liquid` writes `.shopify/metafields.json`, the file Shopify's Liquid language server reads
95
- to complete and hover `product.metafields.custom.promo_text`:
101
+ ```sh
102
+ export SHOPIFY_APP_CLIENT_ID=...
103
+ export SHOPIFY_APP_SECRET=...
104
+ ```
105
+
106
+ The client ID is resolved from `--client-id`, then `--app-config`, then
107
+ `SHOPIFY_APP_CLIENT_ID`. The secret is read only from `SHOPIFY_APP_SECRET`.
96
108
 
97
109
  ```sh
98
- metafields emit ./schema.ts --liquid --out .shopify/metafields.json
110
+ npx @notambourine/metafields ./schema.ts \
111
+ --app-config ./shopify.app.toml --store example.myshopify.com --apply
99
112
  ```
100
113
 
101
- Generating it from the schema means completions work without a store login, and cover definitions
102
- that are declared but not yet created. This drives editor assistance only: no theme-check rule
103
- validates metafields, so nothing here fails a build.
114
+ `--app-config` reads only the top-level `client_id`. Complete app credentials take priority over a
115
+ static token; incomplete app credentials fall back to the token. Credentials are redacted from
116
+ errors.
117
+
118
+ ## Fleets
104
119
 
105
- The file's shape carries less than the schema does. It has no field for `required`, validations, or
106
- access, it cannot represent metaobject definitions, and it has no group for `customer` or
107
- `draft_order` metafields, which are reported as skipped. Treat it as a generated artifact: `emit`
108
- replaces an existing one and refuses to overwrite a file it did not generate. Shopify's own
109
- `shopify theme metafields pull` overwrites the same path, so do not hand-edit it.
120
+ Repeat `--store` or load one store per line from a file. Lines beginning with `#` are ignored.
110
121
 
111
- ## Behavior
122
+ ```sh
123
+ npx @notambourine/metafields ./schema.ts \
124
+ --store flagship.myshopify.com --stores-from ./stores.txt --apply
125
+ ```
112
126
 
113
- - Dry run reports missing definitions without writing them.
114
- - `--apply` creates missing metaobject definitions in dependency order, then metafield definitions.
115
- - `--check` exits nonzero for missing or incompatible operational shape.
116
- - Cosmetic name and description drift is reported but never changed.
117
- - Existing definitions, values, and entries are never updated or deleted by schema sync.
118
- - A description over 255 characters fails `--validate` and fails sync before the first request,
119
- listing every offender at once. The Admin API answers `TOO_LONG`, and one create rejected
120
- mid-run leaves a store half-applied behind an error that reads transient.
127
+ Each store is planned against the same schema. One store refusing a write does not stop the others.
128
+ A store named directly fails loudly; a swept store without the app is reported as `NOT-INSTALLED`
129
+ without failing the fleet. Other unreachable stores and rejected writes exit `2`.
121
130
 
122
- Exit `0` means the selected condition is satisfied, exit `1` means schema or migration drift, and
123
- exit `2` means invalid input, indeterminate Shopify state, or an API failure.
131
+ ## Pull and generated output
124
132
 
125
- `pull` requires explicit owners and namespaces:
133
+ Pull existing definitions into a new schema file:
126
134
 
127
135
  ```sh
128
- metafields pull --store example.myshopify.com \
129
- --owner product --namespace custom --metaobjects --out schema.ts
136
+ npx @notambourine/metafields pull \
137
+ --store example.myshopify.com \
138
+ --owner product \
139
+ --namespace custom \
140
+ --metaobjects \
141
+ --out schema.ts
130
142
  ```
131
143
 
132
- The output path must not exist. Without `--out`, the generated module is written to stdout.
144
+ Owners and namespaces must be explicit unless their corresponding `--all-owners` or
145
+ `--all-namespaces` flag is passed. The output path must not exist; omit `--out` to write to stdout.
146
+
147
+ Generate Liquid editor metadata from the schema:
148
+
149
+ ```sh
150
+ npx @notambourine/metafields emit ./schema.ts \
151
+ --liquid --out .shopify/metafields.json
152
+ ```
153
+
154
+ The generated file supports Liquid completion and hover without a store login. It cannot represent
155
+ metaobjects, `required`, validations, access, customer metafields, or draft-order metafields.
156
+ `emit` refuses to replace a file it did not generate unless passed `--force`.
157
+
158
+ ## Types
159
+
160
+ Infer application types from the schema. Required declarations remain required:
161
+
162
+ ```ts
163
+ import type { InferMetafields, InferMetaobjects } from '@notambourine/metafields';
164
+ import schema from './schema.js';
165
+
166
+ type ProductMetafields = InferMetafields<typeof schema>['product'];
167
+ type Faq = InferMetaobjects<typeof schema>['faq'];
168
+ ```
133
169
 
134
170
  ## Migrations
135
171
 
136
- Migrations are declarative, copy-only, and compiled before credentials are introduced:
172
+ Migrations copy values to a new definition. They never retype or delete the source.
137
173
 
138
174
  ```ts
139
175
  import { defineMigration, transforms } from '@notambourine/metafields';
@@ -154,11 +190,30 @@ export default defineMigration({
154
190
  });
155
191
  ```
156
192
 
193
+ Compile before introducing credentials, inspect the plan, then apply it:
194
+
195
+ ```sh
196
+ npx @notambourine/metafields compile ./migration.ts --out ./migration.json
197
+ npx @notambourine/metafields migrate ./migration.json --store example.myshopify.com
198
+ npx @notambourine/metafields migrate ./migration.json --store example.myshopify.com --apply
199
+ ```
200
+
201
+ Migration exit code `1` means rows remain pending.
202
+
203
+ ## API compatibility
204
+
205
+ `doctor` checks that Shopify still serves the selected API version and that the package's generated
206
+ metafield type table matches it. It needs no store or credentials.
207
+
157
208
  ```sh
158
- metafields compile ./migration.ts --out ./migration.json
159
- metafields migrate ./migration.json --store example.myshopify.com
160
- metafields migrate ./migration.json --store example.myshopify.com --apply
209
+ npx @notambourine/metafields doctor
210
+ npx @notambourine/metafields doctor --api-version 2026-07 --json
161
211
  ```
162
212
 
163
- `0.0.x` is prerelease quality. Confirm owner scopes and behavior against a development store before
164
- production use.
213
+ An unsupported version or changed type table is a failed check. An unreachable Shopify registry is
214
+ indeterminate and exits `2`.
215
+
216
+ Run `npx @notambourine/metafields --help` for the complete CLI reference.
217
+
218
+ This `0.x` release is prerelease quality. Confirm scopes and behavior against a development store
219
+ before production use.
@@ -0,0 +1,57 @@
1
+ import type { ExistingField, ExistingMetafield, ExistingMetaobject } from './planner.js';
2
+ export interface RawField {
3
+ key: string;
4
+ name: string;
5
+ description?: string | null;
6
+ type: {
7
+ name: string;
8
+ };
9
+ required?: boolean;
10
+ validations: {
11
+ name: string;
12
+ value: string;
13
+ }[];
14
+ }
15
+ export interface RawMetafield extends RawField {
16
+ id: string;
17
+ namespace: string;
18
+ ownerType: string;
19
+ access: Record<string, string | null>;
20
+ capabilities: Record<string, {
21
+ enabled: boolean;
22
+ }>;
23
+ constraints?: {
24
+ key: string | null;
25
+ values: {
26
+ nodes: {
27
+ value: string;
28
+ }[];
29
+ };
30
+ } | null;
31
+ validationStatus: ExistingMetafield['validationStatus'];
32
+ invalidCount: number;
33
+ }
34
+ export interface RawMetaobject {
35
+ id: string;
36
+ type: string;
37
+ name: string;
38
+ description?: string | null;
39
+ displayNameKey?: string | null;
40
+ access: Record<string, string | null>;
41
+ capabilities: {
42
+ publishable: {
43
+ enabled: boolean;
44
+ };
45
+ translatable: {
46
+ enabled: boolean;
47
+ };
48
+ };
49
+ fieldDefinitions: RawField[];
50
+ }
51
+ export declare function mapField(value: RawField): ExistingField;
52
+ export declare function mapMetafield(value: RawMetafield): ExistingMetafield;
53
+ export declare function mapMetaobject(value: RawMetaobject): ExistingMetaobject;
54
+ export declare const FIELD_SELECTION = "\n key name description type { name } required validations { name value }\n";
55
+ export declare const METAFIELD_SELECTION = "\n id namespace key ownerType name description type { name }\n validations { name value }\n access { admin storefront customerAccount }\n capabilities {\n adminFilterable { enabled }\n analyticsQueryable { enabled }\n cartToOrderCopyable { enabled }\n smartCollectionCondition { enabled }\n uniqueValues { enabled }\n }\n constraints { key values(first: 250) { nodes { value } } }\n validationStatus\n invalidCount: metafieldsCount(validationStatus: INVALID)\n";
56
+ export declare const METAOBJECT_SELECTION = "\n id type name description displayNameKey\n access { admin storefront }\n capabilities { publishable { enabled } translatable { enabled } }\n fieldDefinitions { \n key name description type { name } required validations { name value }\n }\n";
57
+ //# sourceMappingURL=admin-shapes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-shapes.d.ts","sourceRoot":"","sources":["../src/admin-shapes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEzF,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KA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AE,aAAa,GAAG,kBAAkB,CActE;AAID,eAAO,MAAM,eAAe,iFAE3B,CAAC;AAEF,eAAO,MAAM,mBAAmB,weAc/B,CAAC;AAEF,eAAO,MAAM,oBAAoB,2PAKhC,CAAC"}
@@ -0,0 +1,67 @@
1
+ export function mapField(value) {
2
+ return {
3
+ key: value.key,
4
+ name: value.name,
5
+ description: value.description,
6
+ type: value.type,
7
+ required: value.required,
8
+ validations: value.validations,
9
+ };
10
+ }
11
+ export function mapMetafield(value) {
12
+ return {
13
+ ...mapField(value),
14
+ id: value.id,
15
+ namespace: value.namespace,
16
+ ownerType: value.ownerType,
17
+ access: value.access,
18
+ capabilities: Object.fromEntries(Object.entries(value.capabilities).map(([key, item]) => [key, item.enabled])),
19
+ constraints: value.constraints
20
+ ? { key: value.constraints.key, values: value.constraints.values.nodes.map((item) => item.value) }
21
+ : null,
22
+ validationStatus: value.validationStatus,
23
+ invalidCount: value.invalidCount,
24
+ };
25
+ }
26
+ export function mapMetaobject(value) {
27
+ return {
28
+ id: value.id,
29
+ type: value.type,
30
+ name: value.name,
31
+ description: value.description,
32
+ displayNameKey: value.displayNameKey,
33
+ access: value.access,
34
+ capabilities: {
35
+ publishable: value.capabilities.publishable.enabled,
36
+ translatable: value.capabilities.translatable.enabled,
37
+ },
38
+ fields: value.fieldDefinitions.map(mapField),
39
+ };
40
+ }
41
+ // Read and pull select the same definitions, so the selections live with the shapes they decode:
42
+ // a capability Shopify adds is then one edit, not two that can silently disagree.
43
+ export const FIELD_SELECTION = `
44
+ key name description type { name } required validations { name value }
45
+ `;
46
+ export const METAFIELD_SELECTION = `
47
+ id namespace key ownerType name description type { name }
48
+ validations { name value }
49
+ access { admin storefront customerAccount }
50
+ capabilities {
51
+ adminFilterable { enabled }
52
+ analyticsQueryable { enabled }
53
+ cartToOrderCopyable { enabled }
54
+ smartCollectionCondition { enabled }
55
+ uniqueValues { enabled }
56
+ }
57
+ constraints { key values(first: 250) { nodes { value } } }
58
+ validationStatus
59
+ invalidCount: metafieldsCount(validationStatus: INVALID)
60
+ `;
61
+ export const METAOBJECT_SELECTION = `
62
+ id type name description displayNameKey
63
+ access { admin storefront }
64
+ capabilities { publishable { enabled } translatable { enabled } }
65
+ fieldDefinitions { ${FIELD_SELECTION} }
66
+ `;
67
+ //# sourceMappingURL=admin-shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-shapes.js","sourceRoot":"","sources":["../src/admin-shapes.ts"],"names":[],"mappings":"AAiCA,MAAM,UAAU,QAAQ,CAAC,KAAe;IACtC,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAmB;IAC9C,OAAO;QACL,GAAG,QAAQ,CAAC,KAAK,CAAC;QAClB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9G,WAAW,EAAE,KAAK,CAAC,WAAW;YAC5B,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAClG,CAAC,CAAC,IAAI;QACR,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,YAAY,EAAE,KAAK,CAAC,YAAY;KACjC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAoB;IAChD,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,YAAY,EAAE;YACZ,WAAW,EAAE,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO;YACnD,YAAY,EAAE,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,OAAO;SACtD;QACD,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;KAC7C,CAAC;AACJ,CAAC;AAED,iGAAiG;AACjG,kFAAkF;AAClF,MAAM,CAAC,MAAM,eAAe,GAAG;;CAE9B,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;CAclC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;uBAIb,eAAe;CACrC,CAAC"}
package/dist/admin.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { CanonicalMetafield, CanonicalMetaobject, CompiledSchema } from './schema.js';
2
2
  import type { ExistingMetafield, ExistingMetaobject, ExistingSchema, Plan, SyncMode } from './planner.js';
3
+ import { type DriftItem, type DriftPlan } from './changes.js';
3
4
  export declare const DEFAULT_API_VERSION = "2026-07";
4
5
  export declare class AdminError extends Error {
5
6
  readonly requestId?: string;
@@ -27,12 +28,16 @@ export declare class AdminClient {
27
28
  readMetafield(definition: Pick<CanonicalMetafield, 'ownerType' | 'namespace' | 'key'>): Promise<ExistingMetafield | null>;
28
29
  createMetaobject(definition: CanonicalMetaobject): Promise<void>;
29
30
  createMetafield(definition: CanonicalMetafield): Promise<void>;
31
+ updateMetaobject(entry: DriftItem, force?: boolean): Promise<void>;
32
+ updateMetafield(entry: DriftItem, force?: boolean): Promise<void>;
30
33
  }
31
34
  export interface ApplyResult {
32
35
  plan: Plan;
33
- applied: string[];
36
+ created: string[];
37
+ updated: string[];
38
+ skipped: string[];
34
39
  }
35
40
  export declare function planStore(client: AdminClient, schema: CompiledSchema): Promise<Plan>;
36
- export declare function applyPlan(client: AdminClient, schema: CompiledSchema, plan: Plan): Promise<ApplyResult>;
37
- export declare function synchronize(client: AdminClient, schema: CompiledSchema, mode: SyncMode): Promise<ApplyResult>;
41
+ export declare function applyPlan(client: AdminClient, schema: CompiledSchema, plan: Plan, drift: DriftPlan, force?: boolean): Promise<ApplyResult>;
42
+ export declare function synchronize(client: AdminClient, schema: CompiledSchema, mode: SyncMode, force?: boolean): Promise<ApplyResult>;
38
43
  //# sourceMappingURL=admin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG1G,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,qBAAa,UAAW,SAAQ,KAAK;IACnC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,YAAY,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAI9C;CACF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAID,wBAAgB,aAAa,CAAC,O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