octocms 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/dist/agentDocs-Z5BI2Y2G.js +38 -0
- package/dist/agentDocs-Z5BI2Y2G.js.map +1 -0
- package/dist/chunk-4MPOTHTY.js +9 -0
- package/dist/chunk-4MPOTHTY.js.map +1 -0
- package/dist/chunk-4VLN5EX2.js +9204 -0
- package/dist/chunk-4VLN5EX2.js.map +1 -0
- package/dist/chunk-6PHFHGTZ.js +35 -0
- package/dist/chunk-6PHFHGTZ.js.map +1 -0
- package/dist/chunk-7CFFE2I6.js +55 -0
- package/dist/chunk-7CFFE2I6.js.map +1 -0
- package/dist/chunk-B47VXAHT.js +28 -0
- package/dist/chunk-B47VXAHT.js.map +1 -0
- package/dist/chunk-BRTXBBVQ.js +46 -0
- package/dist/chunk-BRTXBBVQ.js.map +1 -0
- package/dist/chunk-C62C776U.js +79 -0
- package/dist/chunk-C62C776U.js.map +1 -0
- package/dist/chunk-I7KNSICQ.js +114 -0
- package/dist/chunk-I7KNSICQ.js.map +1 -0
- package/dist/chunk-Q73JSGXV.js +123 -0
- package/dist/chunk-Q73JSGXV.js.map +1 -0
- package/dist/chunk-W6QJTGBC.js +57 -0
- package/dist/chunk-W6QJTGBC.js.map +1 -0
- package/dist/cli/index.js +196 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/components/public/index.d.mts +40 -0
- package/dist/components/public/index.js +401 -0
- package/dist/components/public/index.js.map +1 -0
- package/dist/config.d.mts +4 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -0
- package/dist/defineConfig.d.mts +126 -0
- package/dist/defineConfig.js +8 -0
- package/dist/defineConfig.js.map +1 -0
- package/dist/dev-QY534GEH.js +87 -0
- package/dist/dev-QY534GEH.js.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/init-UGUTJFFI.js +145 -0
- package/dist/init-UGUTJFFI.js.map +1 -0
- package/dist/jiti-VYEW7A6R.js +3068 -0
- package/dist/jiti-VYEW7A6R.js.map +1 -0
- package/dist/localReader-I2THES24.js +40 -0
- package/dist/localReader-I2THES24.js.map +1 -0
- package/dist/query.d.mts +112 -0
- package/dist/query.js +11 -0
- package/dist/query.js.map +1 -0
- package/dist/types.d.mts +352 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/typesGen-WBC6CNBG.js +241 -0
- package/dist/typesGen-WBC6CNBG.js.map +1 -0
- package/dist/update-RMGZMS56.js +57 -0
- package/dist/update-RMGZMS56.js.map +1 -0
- package/dist/validate-OTJ6ULMP.js +297 -0
- package/dist/validate-OTJ6ULMP.js.map +1 -0
- package/dist/withOctoCMS.d.mts +6 -0
- package/dist/withOctoCMS.js +9 -0
- package/dist/withOctoCMS.js.map +1 -0
- package/docs/index.md +27 -0
- package/docs/overview.md +113 -0
- package/docs/schema.md +279 -0
- package/globals.css +198 -0
- package/package.json +116 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
agentsMdSection,
|
|
3
|
+
agentsMdTemplate
|
|
4
|
+
} from "./chunk-I7KNSICQ.js";
|
|
5
|
+
import {
|
|
6
|
+
log
|
|
7
|
+
} from "./chunk-6PHFHGTZ.js";
|
|
8
|
+
import "./chunk-W6QJTGBC.js";
|
|
9
|
+
|
|
10
|
+
// cli/commands/agentDocs.ts
|
|
11
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
12
|
+
import { join } from "path";
|
|
13
|
+
async function agentDocsCommand(projectRoot) {
|
|
14
|
+
log.header("Agent documentation");
|
|
15
|
+
const agentsMdPath = join(projectRoot, "AGENTS.md");
|
|
16
|
+
const MARKER = "<!-- octocms:agent-docs -->";
|
|
17
|
+
if (!existsSync(agentsMdPath)) {
|
|
18
|
+
writeFileSync(agentsMdPath, agentsMdTemplate(), "utf8");
|
|
19
|
+
log.success("AGENTS.md \u2014 created with OctoCMS agent docs section");
|
|
20
|
+
} else {
|
|
21
|
+
const current = readFileSync(agentsMdPath, "utf8");
|
|
22
|
+
if (current.includes(MARKER)) {
|
|
23
|
+
log.success("AGENTS.md \u2014 OctoCMS section already present");
|
|
24
|
+
} else {
|
|
25
|
+
const updated = current.trimEnd() + "\n\n" + agentsMdSection() + "\n";
|
|
26
|
+
writeFileSync(agentsMdPath, updated, "utf8");
|
|
27
|
+
log.step("AGENTS.md \u2014 appended OctoCMS agent docs section");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
log.blank();
|
|
31
|
+
log.info("AI agents can now read octocms/docs/ for content management instructions.");
|
|
32
|
+
log.info("Regenerate the docs after schema changes: npm run agent-docs:gen");
|
|
33
|
+
log.blank();
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
agentDocsCommand
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=agentDocs-Z5BI2Y2G.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../cli/commands/agentDocs.ts"],"sourcesContent":["/**\n * `octocms agent-docs` — Inject AI agent documentation links into AGENTS.md.\n *\n * Creates AGENTS.md if it doesn't exist, or appends the OctoCMS section\n * if the file exists but doesn't contain it yet.\n */\n\nimport { existsSync, readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\n\nimport { log } from '../lib/logger';\nimport { agentsMdSection, agentsMdTemplate } from '../lib/templates';\n\nexport async function agentDocsCommand(projectRoot: string): Promise<void> {\n log.header('Agent documentation');\n\n const agentsMdPath = join(projectRoot, 'AGENTS.md');\n const MARKER = '<!-- octocms:agent-docs -->';\n\n if (!existsSync(agentsMdPath)) {\n writeFileSync(agentsMdPath, agentsMdTemplate(), 'utf8');\n log.success('AGENTS.md — created with OctoCMS agent docs section');\n } else {\n const current = readFileSync(agentsMdPath, 'utf8');\n if (current.includes(MARKER)) {\n log.success('AGENTS.md — OctoCMS section already present');\n } else {\n const updated = current.trimEnd() + '\\n\\n' + agentsMdSection() + '\\n';\n writeFileSync(agentsMdPath, updated, 'utf8');\n log.step('AGENTS.md — appended OctoCMS agent docs section');\n }\n }\n\n log.blank();\n log.info('AI agents can now read octocms/docs/ for content management instructions.');\n log.info('Regenerate the docs after schema changes: npm run agent-docs:gen');\n log.blank();\n}\n"],"mappings":";;;;;;;;;;AAOA,SAAS,YAAY,cAAc,qBAAqB;AACxD,SAAS,YAAY;AAKrB,eAAsB,iBAAiB,aAAoC;AACzE,MAAI,OAAO,qBAAqB;AAEhC,QAAM,eAAe,KAAK,aAAa,WAAW;AAClD,QAAM,SAAS;AAEf,MAAI,CAAC,WAAW,YAAY,GAAG;AAC7B,kBAAc,cAAc,iBAAiB,GAAG,MAAM;AACtD,QAAI,QAAQ,0DAAqD;AAAA,EACnE,OAAO;AACL,UAAM,UAAU,aAAa,cAAc,MAAM;AACjD,QAAI,QAAQ,SAAS,MAAM,GAAG;AAC5B,UAAI,QAAQ,kDAA6C;AAAA,IAC3D,OAAO;AACL,YAAM,UAAU,QAAQ,QAAQ,IAAI,SAAS,gBAAgB,IAAI;AACjE,oBAAc,cAAc,SAAS,MAAM;AAC3C,UAAI,KAAK,sDAAiD;AAAA,IAC5D;AAAA,EACF;AAEA,MAAI,MAAM;AACV,MAAI,KAAK,2EAA2E;AACpF,MAAI,KAAK,kEAAkE;AAC3E,MAAI,MAAM;AACZ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../defineConfig.ts"],"sourcesContent":["import type { Config, ResolvedImageField, RichTextDocument } from './types';\n\n/**\n * Define the CMS configuration with full literal type inference.\n *\n * Wrapping your config in `defineConfig()` preserves exact collection names,\n * field names, and field formats as literal types — enabling type-safe queries\n * with autocomplete in `cms/query.ts`.\n *\n * Use `as const` on `select` field `options` (and `defaultOptions`) so option\n * `value`s infer as string literal unions in `InferFields`.\n *\n * @example\n * ```ts\n * // cms/octocms.config.ts\n * import { defineConfig } from 'octocms/defineConfig';\n *\n * export const config = defineConfig({\n * projectName: 'My Site',\n * git: { baseBranch: 'main', publishedPointerBranch: 'cms/publish-pointer' },\n * collections: { post: { label: 'Post', hasMany: true, fields: { ... } } },\n * // ...\n * });\n * ```\n */\nexport function defineConfig<T extends Config>(config: T): T {\n return config;\n}\n\n// ---------------------------------------------------------------------------\n// Type utilities — infer entry shapes from a defineConfig() config literal\n// ---------------------------------------------------------------------------\n\n/** Map a field `format` string to the runtime TypeScript type it produces after processing. */\nexport type FieldFormatToType = {\n string: string;\n text: string;\n markdown: string;\n richtext: RichTextDocument;\n boolean: 'true' | 'false';\n number: number | null;\n datetime: string | null;\n image: ResolvedImageField;\n reference: unknown;\n json: unknown;\n slug: string;\n select: string;\n url: string;\n color: string;\n conditional: unknown;\n};\n\n/** Union of option `value` literals when `options` is a readonly tuple. */\ntype OptionValues<Opts> =\n Opts extends ReadonlyArray<{ readonly value: infer V }> ? (V extends string ? V : string) : string;\n\n/** Extract the collection names defined in a config object. */\nexport type CollectionNames<C extends Config> = Extract<keyof C['collections'], string>;\n\n// ---------------------------------------------------------------------------\n// Conditional field type inference\n// ---------------------------------------------------------------------------\n\n/** Infer the resolved value type for a single field definition. */\ntype InferSingleFieldType<F> = F extends { format: 'string'; list: true }\n ? string[]\n : F extends { format: 'boolean' }\n ? 'true' | 'false'\n : F extends { format: 'select'; multiple: true; options: infer Opts }\n ? OptionValues<Opts>[]\n : F extends { format: 'select'; options: infer Opts }\n ? OptionValues<Opts>\n : F extends {\n format: 'conditional';\n conditional: { branches: infer B };\n }\n ? InferConditionalValue<B>\n : F extends { format: infer Fmt }\n ? Fmt extends keyof FieldFormatToType\n ? FieldFormatToType[Fmt]\n : unknown\n : unknown;\n\n/** Infer the inline fields type for a branch's fields record. */\ntype InferBranchInlineFields<Fields> = {\n [K in Extract<keyof Fields, string>]: InferSingleFieldType<Fields[K]>;\n};\n\n/**\n * Infer the value type for a single branch.\n * - Inline branch (`fields`): produces an object type mapping field names to their inferred types.\n * - Reference branch (`collection`): produces `unknown` (resolved at runtime to the referenced entry).\n */\ntype InferBranchValue<B> = B extends { fields: infer F } ? InferBranchInlineFields<F> : unknown;\n\n/**\n * Infer the union of all branch value types for a conditional field.\n * This is the type the consumer gets after selecting a branch at query time.\n */\ntype InferConditionalValue<Branches> = Branches extends readonly [infer Head, ...infer Tail]\n ? InferBranchValue<Head> | InferConditionalValue<Tail>\n : never;\n\n/**\n * Extract the literal union of branch `key` strings from a conditional field's branches tuple.\n * Requires `as const` on the branches array in `cms/octocms.config.ts` for literal inference.\n */\nexport type InferConditionalKeys<Branches> = Branches extends readonly [infer Head, ...infer Tail]\n ? (Head extends { key: infer K } ? (K extends string ? K : never) : never) | InferConditionalKeys<Tail>\n : never;\n\n// ---------------------------------------------------------------------------\n// InferFields / InferEntry\n// ---------------------------------------------------------------------------\n\n/** Infer the `fields` shape for a collection, mapping each field format to its TS type. */\nexport type InferFields<C extends Config, Name extends CollectionNames<C>> = C['collections'][Name] extends {\n fields: infer F;\n}\n ? {\n [K in Extract<keyof F, string>]: InferSingleFieldType<F[K]>;\n }\n : Record<string, unknown>;\n\n/** A fully-typed content entry for a given collection. */\nexport type InferEntry<C extends Config, Name extends CollectionNames<C>> = {\n sys: { id: string; type: Name };\n fields: InferFields<C, Name>;\n};\n\n// ---------------------------------------------------------------------------\n// InferConditions — extract the required `conditions` record for `query()`\n// ---------------------------------------------------------------------------\n\n/**\n * For a single collection, build `Record<fieldName, branchKeyUnion>` for every `format: 'conditional'` field.\n * If the collection has no conditional fields this resolves to `{}` (empty object / `never` keys).\n */\nexport type InferConditions<C extends Config, Name extends CollectionNames<C>> = C['collections'][Name] extends {\n fields: infer F;\n}\n ? {\n [K in Extract<keyof F, string> as F[K] extends { format: 'conditional' } ? K : never]: F[K] extends {\n conditional: { branches: infer B };\n }\n ? InferConditionalKeys<B>\n : never;\n }\n : {};\n"],"mappings":";AAyBO,SAAS,aAA+B,QAAc;AAC3D,SAAO;AACT;","names":[]}
|