@01.software/init
Advanced tools
| #!/usr/bin/env node | ||
| import { | ||
| fetchTenantContext, | ||
| generateClaudeMd, | ||
| getSkillFiles | ||
| } from "./chunk-SRLZ5OIV.js"; | ||
| export { | ||
| fetchTenantContext, | ||
| generateClaudeMd, | ||
| getSkillFiles | ||
| }; | ||
| //# sourceMappingURL=ai-docs.js.map |
| {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]} |
| #!/usr/bin/env node | ||
| // src/ai-docs.ts | ||
| function normalizeActiveCollections(collections) { | ||
| if (Array.isArray(collections?.active)) return collections.active; | ||
| return []; | ||
| } | ||
| function generateClaudeMd(ctx) { | ||
| const featuresSection = ctx.features && ctx.features.length > 0 ? ctx.features.map((f) => `- ${f}`).join("\n") : "- See console"; | ||
| const collectionsSection = ctx.collections && ctx.collections.length > 0 ? ctx.collections.join(", ") : "Run `01 schema list`"; | ||
| return `# 01.software SDK \u2014 ${ctx.tenantName} | ||
| ## Connection | ||
| - Publishable Key: \`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\` (env) | ||
| - Secret Key: \`SOFTWARE_SECRET_KEY\` (env) | ||
| - MCP: \`.mcp.json\` | ||
| ## Active Features | ||
| ${featuresSection} | ||
| ## Active Collections | ||
| ${collectionsSection} | ||
| ## MCP Quick Reference | ||
| | Tool | Use | | ||
| |------|-----| | ||
| | \`query-collection\` | List/filter documents | | ||
| | \`create-collection\` | Create documents | | ||
| | \`update-field-config\` | Hide unused fields | | ||
| | \`get-tenant-context\` | Show active features & collections | | ||
| ## CLI | ||
| - \`01 query <collection>\` \u2014 query data | ||
| - \`01 schema show <collection>\` \u2014 inspect fields | ||
| - \`01 schema list\` \u2014 list all collections | ||
| ## Initial Setup | ||
| Run \`/01software-field-config\` in Claude Code to configure field visibility for your use case. | ||
| Use \`get-collection-schema\` or \`01 schema show <collection>\` for live field introspection instead of relying on this document as a schema snapshot. | ||
| `; | ||
| } | ||
| function getSkillFiles() { | ||
| return [ | ||
| { | ||
| dirName: "01software-field-config", | ||
| content: `--- | ||
| name: 01software-field-config | ||
| description: Configure field visibility for this tenant \u2014 hide unused collections and fields via MCP | ||
| disable-model-invocation: true | ||
| --- | ||
| Steps: | ||
| 1. Use \`list-configurable-fields\` to see current visibility settings | ||
| 2. Identify fields/collections not needed for your use case | ||
| 3. Use \`update-field-config\` to hide them | ||
| Common setups: | ||
| - Blog only: hide \`ecommerce\`, \`customers\`, \`videos\` collections | ||
| - Store: hide \`posts\`, \`documents\`, \`galleries\`, \`canvas\` collections | ||
| - Minimal: hide all except the collections you actively use | ||
| Ask me: "Show current field config" or "Hide ecommerce fields" | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-query", | ||
| content: `--- | ||
| name: 01software-query | ||
| description: Query 01.software collections via MCP or CLI with filter, sort, and pagination examples | ||
| --- | ||
| Query collections using the MCP \`query-collection\` tool or CLI. | ||
| MCP examples: | ||
| - List products: \`query-collection\` with collection="products", limit=10 | ||
| - Filter by status: add where={"status":{"equals":"published"}} | ||
| - Sort by date: sort="-createdAt" | ||
| - Paginate: page=2, limit=20 | ||
| CLI examples: | ||
| - \`01 query products --limit 10\` | ||
| - \`01 query orders --where '{"status":{"equals":"paid"}}'\` | ||
| - \`01 schema show products\` \u2014 inspect available fields | ||
| SDK (server): | ||
| \`\`\`typescript | ||
| const { docs } = await serverClient.collection('products').find({ | ||
| where: { status: { equals: 'published' } }, | ||
| sort: '-createdAt', | ||
| limit: 10, | ||
| }) | ||
| \`\`\` | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-order-flow", | ||
| content: `--- | ||
| name: 01software-order-flow | ||
| description: Order lifecycle reference \u2014 create, pay, fulfill, and return flows for 01.software | ||
| --- | ||
| Complete order flow from creation to fulfillment. | ||
| States: pending \u2192 paid \u2192 preparing \u2192 shipped \u2192 delivered \u2192 confirmed | ||
| 1. Create order: \`create-order\` with orderNumber, customerSnapshot, orderProducts, totalAmount | ||
| 2. Mark paid: \`update-order\` with status="paid" (after payment gateway confirms) | ||
| 3. Fulfill: \`create-fulfillment\` with items and carrier/trackingNumber | ||
| 4. Returns: \`create-return\` or \`return-with-refund\` (atomic) | ||
| Free orders: omit paymentId, totalAmount=0 \u2192 auto-transitions to paid | ||
| CLI: \`01 order create --help\` for full options | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-schema", | ||
| content: `--- | ||
| name: 01software-schema | ||
| description: Inspect 01.software collection schemas and available fields via MCP or CLI | ||
| --- | ||
| Inspect collection schemas to understand available fields. | ||
| MCP: use \`get-collection-schema\` with collection | ||
| CLI: | ||
| - \`01 schema list\` \u2014 all available collections | ||
| - \`01 schema show <collection>\` \u2014 field names, types, required status | ||
| Common collections: products, orders, customers, posts, documents, images | ||
| Use \`get-tenant-context\` to see which collections are active for this tenant. | ||
| ` | ||
| } | ||
| ]; | ||
| } | ||
| async function fetchTenantContext(publishableKey, secretKey) { | ||
| try { | ||
| const apiUrl = process.env.SOFTWARE_API_URL || "https://api.01.software"; | ||
| const res = await fetch(`${apiUrl}/api/tenants/context`, { | ||
| headers: { | ||
| "X-Publishable-Key": publishableKey, | ||
| Authorization: `Bearer ${secretKey}` | ||
| } | ||
| }); | ||
| if (!res.ok) return null; | ||
| const data = await res.json(); | ||
| return { | ||
| tenantName: data.tenant?.name || "", | ||
| features: data.features || [], | ||
| collections: normalizeActiveCollections(data.collections) | ||
| }; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
| export { | ||
| generateClaudeMd, | ||
| getSkillFiles, | ||
| fetchTenantContext | ||
| }; | ||
| //# sourceMappingURL=chunk-SRLZ5OIV.js.map |
| {"version":3,"sources":["../src/ai-docs.ts"],"sourcesContent":["export interface TenantContext {\n tenantName: string\n features?: string[]\n collections?: string[]\n}\n\ninterface TenantContextApiResponse {\n tenant?: { name?: string }\n features?: string[]\n collections?: { active?: string[]; inactive?: string[] }\n}\n\nfunction normalizeActiveCollections(\n collections: TenantContextApiResponse['collections'],\n): string[] {\n if (Array.isArray(collections?.active)) return collections.active\n return []\n}\n\n// ── CLAUDE.md ────────────────────────────────────────────────────────\n\nexport function generateClaudeMd(ctx: TenantContext): string {\n const featuresSection =\n ctx.features && ctx.features.length > 0\n ? ctx.features.map((f) => `- ${f}`).join('\\n')\n : '- See console'\n\n const collectionsSection =\n ctx.collections && ctx.collections.length > 0\n ? ctx.collections.join(', ')\n : 'Run `01 schema list`'\n\n return `# 01.software SDK — ${ctx.tenantName}\n\n## Connection\n- Publishable Key: \\`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\\` (env)\n- Secret Key: \\`SOFTWARE_SECRET_KEY\\` (env)\n- MCP: \\`.mcp.json\\`\n\n## Active Features\n${featuresSection}\n\n## Active Collections\n${collectionsSection}\n\n## MCP Quick Reference\n| Tool | Use |\n|------|-----|\n| \\`query-collection\\` | List/filter documents |\n| \\`create-collection\\` | Create documents |\n| \\`update-field-config\\` | Hide unused fields |\n| \\`get-tenant-context\\` | Show active features & collections |\n\n## CLI\n- \\`01 query <collection>\\` — query data\n- \\`01 schema show <collection>\\` — inspect fields\n- \\`01 schema list\\` — list all collections\n\n## Initial Setup\nRun \\`/01software-field-config\\` in Claude Code to configure field visibility for your use case.\nUse \\`get-collection-schema\\` or \\`01 schema show <collection>\\` for live field introspection instead of relying on this document as a schema snapshot.\n`\n}\n\n// ── Skill files ──────────────────────────────────────────────────────\n\nexport function getSkillFiles(): Array<{ dirName: string; content: string }> {\n return [\n {\n dirName: '01software-field-config',\n content: `---\nname: 01software-field-config\ndescription: Configure field visibility for this tenant — hide unused collections and fields via MCP\ndisable-model-invocation: true\n---\n\nSteps:\n1. Use \\`list-configurable-fields\\` to see current visibility settings\n2. Identify fields/collections not needed for your use case\n3. Use \\`update-field-config\\` to hide them\n\nCommon setups:\n- Blog only: hide \\`ecommerce\\`, \\`customers\\`, \\`videos\\` collections\n- Store: hide \\`posts\\`, \\`documents\\`, \\`galleries\\`, \\`canvas\\` collections\n- Minimal: hide all except the collections you actively use\n\nAsk me: \"Show current field config\" or \"Hide ecommerce fields\"\n`,\n },\n {\n dirName: '01software-query',\n content: `---\nname: 01software-query\ndescription: Query 01.software collections via MCP or CLI with filter, sort, and pagination examples\n---\n\nQuery collections using the MCP \\`query-collection\\` tool or CLI.\n\nMCP examples:\n- List products: \\`query-collection\\` with collection=\"products\", limit=10\n- Filter by status: add where={\"status\":{\"equals\":\"published\"}}\n- Sort by date: sort=\"-createdAt\"\n- Paginate: page=2, limit=20\n\nCLI examples:\n- \\`01 query products --limit 10\\`\n- \\`01 query orders --where '{\"status\":{\"equals\":\"paid\"}}'\\`\n- \\`01 schema show products\\` — inspect available fields\n\nSDK (server):\n\\`\\`\\`typescript\nconst { docs } = await serverClient.collection('products').find({\n where: { status: { equals: 'published' } },\n sort: '-createdAt',\n limit: 10,\n})\n\\`\\`\\`\n`,\n },\n {\n dirName: '01software-order-flow',\n content: `---\nname: 01software-order-flow\ndescription: Order lifecycle reference — create, pay, fulfill, and return flows for 01.software\n---\n\nComplete order flow from creation to fulfillment.\n\nStates: pending → paid → preparing → shipped → delivered → confirmed\n\n1. Create order: \\`create-order\\` with orderNumber, customerSnapshot, orderProducts, totalAmount\n2. Mark paid: \\`update-order\\` with status=\"paid\" (after payment gateway confirms)\n3. Fulfill: \\`create-fulfillment\\` with items and carrier/trackingNumber\n4. Returns: \\`create-return\\` or \\`return-with-refund\\` (atomic)\n\nFree orders: omit paymentId, totalAmount=0 → auto-transitions to paid\n\nCLI: \\`01 order create --help\\` for full options\n`,\n },\n {\n dirName: '01software-schema',\n content: `---\nname: 01software-schema\ndescription: Inspect 01.software collection schemas and available fields via MCP or CLI\n---\n\nInspect collection schemas to understand available fields.\n\nMCP: use \\`get-collection-schema\\` with collection\n\nCLI:\n- \\`01 schema list\\` — all available collections\n- \\`01 schema show <collection>\\` — field names, types, required status\n\nCommon collections: products, orders, customers, posts, documents, images\nUse \\`get-tenant-context\\` to see which collections are active for this tenant.\n`,\n },\n ]\n}\n\n// ── Tenant context fetch ─────────────────────────────────────────────\n\nexport async function fetchTenantContext(\n publishableKey: string,\n secretKey: string,\n): Promise<TenantContext | null> {\n try {\n const apiUrl = process.env.SOFTWARE_API_URL || 'https://api.01.software'\n // secretKey is now an opaque sk01_/pat01_ bearer token — send it directly.\n const res = await fetch(`${apiUrl}/api/tenants/context`, {\n headers: {\n 'X-Publishable-Key': publishableKey,\n Authorization: `Bearer ${secretKey}`,\n },\n })\n if (!res.ok) return null\n const data = (await res.json()) as TenantContextApiResponse\n return {\n tenantName: data.tenant?.name || '',\n features: data.features || [],\n collections: normalizeActiveCollections(data.collections),\n }\n } catch {\n return null\n }\n}\n"],"mappings":";;;AAYA,SAAS,2BACP,aACU;AACV,MAAI,MAAM,QAAQ,aAAa,MAAM,EAAG,QAAO,YAAY;AAC3D,SAAO,CAAC;AACV;AAIO,SAAS,iBAAiB,KAA4B;AAC3D,QAAM,kBACJ,IAAI,YAAY,IAAI,SAAS,SAAS,IAClC,IAAI,SAAS,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI,IAC3C;AAEN,QAAM,qBACJ,IAAI,eAAe,IAAI,YAAY,SAAS,IACxC,IAAI,YAAY,KAAK,IAAI,IACzB;AAEN,SAAO,4BAAuB,IAAI,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,eAAe;AAAA;AAAA;AAAA,EAGf,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBpB;AAIO,SAAS,gBAA6D;AAC3E,SAAO;AAAA,IACL;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBX;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA2BX;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBX;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBX;AAAA,EACF;AACF;AAIA,eAAsB,mBACpB,gBACA,WAC+B;AAC/B,MAAI;AACF,UAAM,SAAS,QAAQ,IAAI,oBAAoB;AAE/C,UAAM,MAAM,MAAM,MAAM,GAAG,MAAM,wBAAwB;AAAA,MACvD,SAAS;AAAA,QACP,qBAAqB;AAAA,QACrB,eAAe,UAAU,SAAS;AAAA,MACpC;AAAA,IACF,CAAC;AACD,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,UAAM,OAAQ,MAAM,IAAI,KAAK;AAC7B,WAAO;AAAA,MACL,YAAY,KAAK,QAAQ,QAAQ;AAAA,MACjC,UAAU,KAAK,YAAY,CAAC;AAAA,MAC5B,aAAa,2BAA2B,KAAK,WAAW;AAAA,IAC1D;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]} |
+7
-152
| #!/usr/bin/env node | ||
| import { | ||
| fetchTenantContext, | ||
| generateClaudeMd, | ||
| getSkillFiles | ||
| } from "./chunk-SRLZ5OIV.js"; | ||
@@ -174,3 +179,3 @@ // src/index.ts | ||
| name: "publishableKey", | ||
| message: "Client Key (optional, saved to .env)", | ||
| message: "Publishable Key (optional, saved to .env)", | ||
| initial: "" | ||
@@ -522,152 +527,2 @@ }); | ||
| // src/ai-docs.ts | ||
| function generateClaudeMd(ctx) { | ||
| const featuresSection = ctx.features && ctx.features.length > 0 ? ctx.features.map((f) => `- ${f}`).join("\n") : "- See console"; | ||
| const collectionsSection = ctx.collections && ctx.collections.length > 0 ? ctx.collections.join(", ") : "Run `01 schema list`"; | ||
| return `# 01.software SDK \u2014 ${ctx.tenantName} | ||
| ## Connection | ||
| - Publishable Key: \`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\` (env) | ||
| - Secret Key: \`SOFTWARE_SECRET_KEY\` (env) | ||
| - MCP: \`.mcp.json\` | ||
| ## Active Features | ||
| ${featuresSection} | ||
| ## Collections | ||
| ${collectionsSection} | ||
| ## MCP Quick Reference | ||
| | Tool | Use | | ||
| |------|-----| | ||
| | \`query-collection\` | List/filter documents | | ||
| | \`create-collection\` | Create documents | | ||
| | \`update-field-config\` | Hide unused fields | | ||
| | \`get-tenant-context\` | Show active features & collections | | ||
| ## CLI | ||
| - \`01 query <collection>\` \u2014 query data | ||
| - \`01 schema show <collection>\` \u2014 inspect fields | ||
| - \`01 schema list\` \u2014 list all collections | ||
| ## Initial Setup | ||
| Run \`/01software-field-config\` in Claude Code to configure field visibility for your use case. | ||
| `; | ||
| } | ||
| function getSkillFiles() { | ||
| return [ | ||
| { | ||
| dirName: "01software-field-config", | ||
| content: `--- | ||
| name: 01software-field-config | ||
| description: Configure field visibility for this tenant \u2014 hide unused collections and fields via MCP | ||
| disable-model-invocation: true | ||
| --- | ||
| Steps: | ||
| 1. Use \`list-configurable-fields\` to see current visibility settings | ||
| 2. Identify fields/collections not needed for your use case | ||
| 3. Use \`update-field-config\` to hide them | ||
| Common setups: | ||
| - Blog only: hide \`ecommerce\`, \`customers\`, \`videos\` collections | ||
| - Store: hide \`posts\`, \`documents\`, \`galleries\`, \`canvas\` collections | ||
| - Minimal: hide all except the collections you actively use | ||
| Ask me: "Show current field config" or "Hide ecommerce fields" | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-query", | ||
| content: `--- | ||
| name: 01software-query | ||
| description: Query 01.software collections via MCP or CLI with filter, sort, and pagination examples | ||
| --- | ||
| Query collections using the MCP \`query-collection\` tool or CLI. | ||
| MCP examples: | ||
| - List products: \`query-collection\` with collection="products", limit=10 | ||
| - Filter by status: add where={"status":{"equals":"published"}} | ||
| - Sort by date: sort="-createdAt" | ||
| - Paginate: page=2, limit=20 | ||
| CLI examples: | ||
| - \`01 query products --limit 10\` | ||
| - \`01 query orders --where '{"status":{"equals":"paid"}}'\` | ||
| - \`01 schema show products\` \u2014 inspect available fields | ||
| SDK (server): | ||
| \`\`\`typescript | ||
| const { docs } = await serverClient.collection('products').find({ | ||
| where: { status: { equals: 'published' } }, | ||
| sort: '-createdAt', | ||
| limit: 10, | ||
| }) | ||
| \`\`\` | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-order-flow", | ||
| content: `--- | ||
| name: 01software-order-flow | ||
| description: Order lifecycle reference \u2014 create, pay, fulfill, and return flows for 01.software | ||
| --- | ||
| Complete order flow from creation to fulfillment. | ||
| States: pending \u2192 paid \u2192 preparing \u2192 shipped \u2192 delivered \u2192 confirmed | ||
| 1. Create order: \`create-order\` with orderNumber, customerSnapshot, orderProducts, totalAmount | ||
| 2. Mark paid: \`update-order\` with status="paid" (after payment gateway confirms) | ||
| 3. Fulfill: \`create-fulfillment\` with items and carrier/trackingNumber | ||
| 4. Returns: \`create-return\` or \`return-with-refund\` (atomic) | ||
| Free orders: omit paymentId, totalAmount=0 \u2192 auto-transitions to paid | ||
| CLI: \`01 order create --help\` for full options | ||
| ` | ||
| }, | ||
| { | ||
| dirName: "01software-schema", | ||
| content: `--- | ||
| name: 01software-schema | ||
| description: Inspect 01.software collection schemas and available fields via MCP or CLI | ||
| --- | ||
| Inspect collection schemas to understand available fields. | ||
| MCP: use \`get-collection-fields\` with collectionSlug | ||
| CLI: | ||
| - \`01 schema list\` \u2014 all available collections | ||
| - \`01 schema show <collection>\` \u2014 field names, types, required status | ||
| Common collections: products, orders, customers, posts, documents, images | ||
| Use \`get-tenant-context\` to see which collections are active for this tenant. | ||
| ` | ||
| } | ||
| ]; | ||
| } | ||
| async function fetchTenantContext(publishableKey, secretKey) { | ||
| try { | ||
| const apiUrl = process.env.SOFTWARE_API_URL || "https://api.01.software"; | ||
| const res = await fetch(`${apiUrl}/api/tenants/context`, { | ||
| headers: { | ||
| "X-Publishable-Key": publishableKey, | ||
| Authorization: `Bearer ${secretKey}` | ||
| } | ||
| }); | ||
| if (!res.ok) return null; | ||
| const data = await res.json(); | ||
| return { | ||
| tenantName: data.tenant?.name || "", | ||
| features: data.features || [], | ||
| collections: data.collections || [] | ||
| }; | ||
| } catch { | ||
| return null; | ||
| } | ||
| } | ||
| // src/init.ts | ||
@@ -971,3 +826,3 @@ var SECRET_KEY_ENV_VAR = "SOFTWARE_SECRET_KEY"; | ||
| 4. Docs: https://01.software/docs/guide/quickstart | ||
| 4. Docs: https://01.software/docs/developers/sdk/client | ||
| `; | ||
@@ -974,0 +829,0 @@ async function main() { |
+2
-1
| { | ||
| "name": "@01.software/init", | ||
| "version": "0.3.0", | ||
| "version": "0.3.1", | ||
| "description": "Initialize 01.software SDK in your project (Next.js, React, Vanilla JS, Node.js, Edge)", | ||
@@ -33,4 +33,5 @@ "type": "module", | ||
| "check-types": "tsc --noEmit", | ||
| "test": "pnpm run build && node --test tests/**/*.test.mjs", | ||
| "release": "node ../../scripts/publish.js" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
110374
1.42%7
133.33%1057
2.62%