@fmaplabs/meta-manifest 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.
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/chunk-3R6VQ3Z3.js +97 -0
- package/dist/chunk-3R6VQ3Z3.js.map +1 -0
- package/dist/chunk-GH5DXHS5.js +1108 -0
- package/dist/chunk-GH5DXHS5.js.map +1 -0
- package/dist/chunk-PFU5VAO7.js +31 -0
- package/dist/chunk-PFU5VAO7.js.map +1 -0
- package/dist/cli/index.cjs +805 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +12 -0
- package/dist/cli/index.d.ts +12 -0
- package/dist/cli/index.js +239 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client-CdkKviW2.d.cts +25 -0
- package/dist/client-CdkKviW2.d.ts +25 -0
- package/dist/index.cjs +1229 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +602 -0
- package/dist/index.d.ts +602 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/node/client.cjs +65 -0
- package/dist/node/client.cjs.map +1 -0
- package/dist/node/client.d.cts +14 -0
- package/dist/node/client.d.ts +14 -0
- package/dist/node/client.js +8 -0
- package/dist/node/client.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/node/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
createAdminClient: () => createAdminClient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(client_exports);
|
|
26
|
+
|
|
27
|
+
// src/sync/client.ts
|
|
28
|
+
var SyncTransportError = class extends Error {
|
|
29
|
+
constructor(message, errors) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.errors = errors;
|
|
32
|
+
this.name = "SyncTransportError";
|
|
33
|
+
}
|
|
34
|
+
errors;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// src/config.ts
|
|
38
|
+
var DEFAULT_API_VERSION = "2026-07";
|
|
39
|
+
|
|
40
|
+
// src/node/client.ts
|
|
41
|
+
function createAdminClient(opts) {
|
|
42
|
+
const version = opts.apiVersion ?? DEFAULT_API_VERSION;
|
|
43
|
+
const endpoint = `https://${opts.shop}/admin/api/${version}/graphql.json`;
|
|
44
|
+
return async (query, options) => {
|
|
45
|
+
let res;
|
|
46
|
+
try {
|
|
47
|
+
res = await fetch(endpoint, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: { "Content-Type": "application/json", "X-Shopify-Access-Token": opts.accessToken },
|
|
50
|
+
body: JSON.stringify({ query, variables: options?.variables })
|
|
51
|
+
});
|
|
52
|
+
} catch (cause) {
|
|
53
|
+
throw new SyncTransportError(`Request to ${opts.shop} failed`, cause);
|
|
54
|
+
}
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
throw new SyncTransportError(`Admin API returned HTTP ${res.status}`, await res.text().catch(() => null));
|
|
57
|
+
}
|
|
58
|
+
return res.json();
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
createAdminClient
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/node/client.ts","../../src/sync/client.ts","../../src/config.ts"],"sourcesContent":["import type { AdminGraphQLClient } from \"../sync/client\";\nimport { SyncTransportError } from \"../sync/client\";\nimport { DEFAULT_API_VERSION } from \"../config\";\n\n/**\n * Build an AdminGraphQLClient that talks directly to a store using an Admin API\n * access token — the CLI's standalone equivalent of the app's session-based\n * `admin.graphql` wrapper. [design §2]\n */\nexport function createAdminClient(opts: {\n shop: string;\n accessToken: string;\n apiVersion?: string;\n}): AdminGraphQLClient {\n const version = opts.apiVersion ?? DEFAULT_API_VERSION;\n const endpoint = `https://${opts.shop}/admin/api/${version}/graphql.json`;\n return async (query, options) => {\n let res: Response;\n try {\n res = await fetch(endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", \"X-Shopify-Access-Token\": opts.accessToken },\n body: JSON.stringify({ query, variables: options?.variables }),\n });\n } catch (cause) {\n throw new SyncTransportError(`Request to ${opts.shop} failed`, cause);\n }\n if (!res.ok) {\n throw new SyncTransportError(`Admin API returned HTTP ${res.status}`, await res.text().catch(() => null));\n }\n return res.json() as Promise<{ data?: unknown; errors?: unknown }>;\n };\n}\n","/**\n * The minimal Admin GraphQL transport the sync adapter depends on. The app\n * supplies a concrete implementation at its edge (wrapping `admin.graphql`),\n * keeping `@fmaplabs/meta-manifest` free of any runtime dependency on a GraphQL\n * client. [design §5]\n */\nexport interface AdminGraphQLClient {\n (query: string, options?: { variables?: Record<string, unknown> }): Promise<{ data?: unknown; errors?: unknown }>;\n}\n\n// GraphQL operation strings, copied verbatim from the schema-validated documents\n// in the design spec §3. Re-validated against Admin API 2026-07 during planning.\n// Do not edit by hand — keep equal to the validated documents (drift guard, §12).\n\nexport const PULL_DEFINITION_QUERY = `query PullMetaobjectDefinition($type: String!) {\n metaobjectDefinitionByType(type: $type) {\n id\n name\n type\n description\n displayNameKey\n fieldDefinitions {\n key\n name\n description\n required\n type { name }\n validations { name value }\n }\n access { admin storefront }\n capabilities {\n publishable { enabled }\n translatable { enabled }\n renderable { enabled }\n }\n }\n}`;\n\nexport const LIST_DEFINITIONS_QUERY = `query ListMetaobjectDefinitions($after: String) {\n metaobjectDefinitions(first: 50, after: $after) {\n nodes {\n id\n name\n type\n fieldDefinitions {\n key\n name\n description\n required\n type { name }\n validations { name value }\n }\n }\n pageInfo { hasNextPage endCursor }\n }\n}`;\n\nexport const CREATE_DEFINITION_MUTATION = `mutation CreateMetaobjectDefinition($definition: MetaobjectDefinitionCreateInput!) {\n metaobjectDefinitionCreate(definition: $definition) {\n metaobjectDefinition { id type }\n userErrors { field message code }\n }\n}`;\n\nexport const UPDATE_DEFINITION_MUTATION = `mutation UpdateMetaobjectDefinition($id: ID!, $definition: MetaobjectDefinitionUpdateInput!) {\n metaobjectDefinitionUpdate(id: $id, definition: $definition) {\n metaobjectDefinition { id type }\n userErrors { field message code }\n }\n}`;\n\n/**\n * Thrown when a request fails at the transport or top-level GraphQL layer —\n * distinct from per-op `userErrors`, which `push` reports as `failed` rather\n * than throwing. Carries the offending top-level `errors` payload. [design §5]\n */\nexport class SyncTransportError extends Error {\n constructor(message: string, readonly errors: unknown) {\n super(message);\n this.name = \"SyncTransportError\";\n }\n}\n\n/**\n * Runs an operation through the injected client and returns its `data`.\n * A non-empty top-level `errors` payload becomes a `SyncTransportError`;\n * a rejected transport promise propagates unchanged. [design §5]\n */\nexport async function execute<T>(\n client: AdminGraphQLClient,\n query: string,\n variables?: Record<string, unknown>,\n): Promise<T> {\n const result = await client(query, variables ? { variables } : undefined);\n if (Array.isArray(result.errors) ? result.errors.length > 0 : result.errors != null) {\n throw new SyncTransportError(\"GraphQL request failed\", result.errors);\n }\n return result.data as T;\n}\n","export const DEFAULT_API_VERSION = \"2026-07\";\n\nexport interface Config {\n /** e.g. \"my-store.myshopify.com\" */\n shop: string;\n /** Admin API access token; reference via process.env in your config file. */\n accessToken: string;\n /** Admin API version. Defaults to DEFAULT_API_VERSION. */\n apiVersion?: string;\n /** Path to the schema module whose `schemas` export drives diff/push, and pull writes. */\n schema: string;\n}\n\n/** Identity helper for type inference in `meta-manifest.config.ts`. */\nexport function defineConfig(config: Config): Config {\n return config;\n}\n\n/** Validate a loaded config object, throwing a one-line Error naming the first missing field. */\nexport function validateConfig(raw: unknown): Config {\n const c = raw as Partial<Config> | null | undefined;\n for (const key of [\"shop\", \"accessToken\", \"schema\"] as const) {\n if (!c || typeof c[key] !== \"string\" || c[key] === \"\") {\n throw new Error(`Invalid config: missing or empty \"${key}\".`);\n }\n }\n return c as Config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC4EO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YAAY,SAA0B,QAAiB;AACrD,UAAM,OAAO;AADuB;AAEpC,SAAK,OAAO;AAAA,EACd;AAAA,EAHsC;AAIxC;;;ACjFO,IAAM,sBAAsB;;;AFS5B,SAAS,kBAAkB,MAIX;AACrB,QAAM,UAAU,KAAK,cAAc;AACnC,QAAM,WAAW,WAAW,KAAK,IAAI,cAAc,OAAO;AAC1D,SAAO,OAAO,OAAO,YAAY;AAC/B,QAAI;AACJ,QAAI;AACF,YAAM,MAAM,MAAM,UAAU;AAAA,QAC1B,QAAQ;AAAA,QACR,SAAS,EAAE,gBAAgB,oBAAoB,0BAA0B,KAAK,YAAY;AAAA,QAC1F,MAAM,KAAK,UAAU,EAAE,OAAO,WAAW,SAAS,UAAU,CAAC;AAAA,MAC/D,CAAC;AAAA,IACH,SAAS,OAAO;AACd,YAAM,IAAI,mBAAmB,cAAc,KAAK,IAAI,WAAW,KAAK;AAAA,IACtE;AACA,QAAI,CAAC,IAAI,IAAI;AACX,YAAM,IAAI,mBAAmB,2BAA2B,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,CAAC;AAAA,IAC1G;AACA,WAAO,IAAI,KAAK;AAAA,EAClB;AACF;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A as AdminGraphQLClient } from '../client-CdkKviW2.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build an AdminGraphQLClient that talks directly to a store using an Admin API
|
|
5
|
+
* access token — the CLI's standalone equivalent of the app's session-based
|
|
6
|
+
* `admin.graphql` wrapper. [design §2]
|
|
7
|
+
*/
|
|
8
|
+
declare function createAdminClient(opts: {
|
|
9
|
+
shop: string;
|
|
10
|
+
accessToken: string;
|
|
11
|
+
apiVersion?: string;
|
|
12
|
+
}): AdminGraphQLClient;
|
|
13
|
+
|
|
14
|
+
export { createAdminClient };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A as AdminGraphQLClient } from '../client-CdkKviW2.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build an AdminGraphQLClient that talks directly to a store using an Admin API
|
|
5
|
+
* access token — the CLI's standalone equivalent of the app's session-based
|
|
6
|
+
* `admin.graphql` wrapper. [design §2]
|
|
7
|
+
*/
|
|
8
|
+
declare function createAdminClient(opts: {
|
|
9
|
+
shop: string;
|
|
10
|
+
accessToken: string;
|
|
11
|
+
apiVersion?: string;
|
|
12
|
+
}): AdminGraphQLClient;
|
|
13
|
+
|
|
14
|
+
export { createAdminClient };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fmaplabs/meta-manifest",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Zero-dependency, zod-style builder for Shopify metaobject definitions, plus a CLI (mm) that syncs them to a store via pull → diff → push.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
11
|
+
},
|
|
12
|
+
"author": "kyle",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/fmaplabs/meta-manifest.git"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/fmaplabs/meta-manifest#readme",
|
|
19
|
+
"bugs": "https://github.com/fmaplabs/meta-manifest/issues",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"shopify",
|
|
22
|
+
"metaobject",
|
|
23
|
+
"metaobjects",
|
|
24
|
+
"metafields",
|
|
25
|
+
"schema",
|
|
26
|
+
"cli",
|
|
27
|
+
"codegen",
|
|
28
|
+
"admin-api"
|
|
29
|
+
],
|
|
30
|
+
"main": "./dist/index.cjs",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js",
|
|
37
|
+
"require": "./dist/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./node": {
|
|
40
|
+
"types": "./dist/node/client.d.ts",
|
|
41
|
+
"import": "./dist/node/client.js",
|
|
42
|
+
"require": "./dist/node/client.cjs"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"bin": {
|
|
46
|
+
"meta-manifest": "./dist/cli/index.js",
|
|
47
|
+
"mm": "./dist/cli/index.js"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"test:watch": "vitest",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"prepublishOnly": "pnpm build",
|
|
58
|
+
"release": "pnpm test && pnpm typecheck && npm publish --access public",
|
|
59
|
+
"release:patch": "npm version patch && pnpm release && git push --follow-tags",
|
|
60
|
+
"release:minor": "npm version minor && pnpm release && git push --follow-tags",
|
|
61
|
+
"release:major": "npm version major && pnpm release && git push --follow-tags"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"jiti": "^2.4.2"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/node": "^22.18.8",
|
|
68
|
+
"tsup": "^8.3.5",
|
|
69
|
+
"tsx": "^4.19.0",
|
|
70
|
+
"typescript": "^5.9.3",
|
|
71
|
+
"vitest": "^2.1.0"
|
|
72
|
+
}
|
|
73
|
+
}
|