@obelism/content 0.10.0 → 0.12.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/README.md CHANGED
@@ -316,7 +316,9 @@ npx @obelism/content model plan # what applying would change
316
316
  npx @obelism/content model apply # apply it, all or nothing
317
317
  ```
318
318
 
319
- Options: `--file`, `--url` (or `$CONTENT_URL`), `--prune`. In GitHub Actions
319
+ Options: `--file`, `--url` (or `$CONTENT_URL`), `--prune`, and for `apply`
320
+ `--lock` (the environment's model becomes managed in code: read-only in the
321
+ dashboard, the agent API and MCP) or `--unlock`. In GitHub Actions
320
322
  the plan is also written to the job summary.
321
323
 
322
324
  ### Types
@@ -285,7 +285,7 @@ const managementApi = (url, token, fetchImpl = fetch)=>async (method, path, body
285
285
  }
286
286
  };
287
287
  // Exit code: 0 done, 1 problems in the plan.
288
- const runModelCommand = async ({ command, file, url, token, prune, log = console.log, summaryFile, fetch: fetchImpl = fetch })=>{
288
+ const runModelCommand = async ({ command, file, url, token, prune, lock, log = console.log, summaryFile, fetch: fetchImpl = fetch })=>{
289
289
  const call = managementApi(url, token, fetchImpl);
290
290
  if (command === 'pull') {
291
291
  const { ok, json } = await call('GET', '/model');
@@ -312,7 +312,10 @@ const runModelCommand = async ({ command, file, url, token, prune, log = console
312
312
  }
313
313
  const { ok, status, json } = await call('POST', command === 'plan' ? '/model/plan' : '/model/apply', {
314
314
  model,
315
- prune
315
+ prune,
316
+ ...command === 'apply' && lock !== undefined && {
317
+ lock
318
+ }
316
319
  });
317
320
  // A plan with issues, or an apply refused for them, still has the plan.
318
321
  const plan = json.changes || json.issues ? json : null;
@@ -321,6 +324,9 @@ const runModelCommand = async ({ command, file, url, token, prune, log = console
321
324
  log(formatPlan(plan, {
322
325
  applied
323
326
  }));
327
+ if (applied && lock !== undefined) {
328
+ log(lock ? 'The model is now managed in code: read-only in the dashboard.' : 'The model can be changed in the dashboard again.');
329
+ }
324
330
  if (summaryFile) {
325
331
  await promises.appendFile(summaryFile, `${formatPlan(plan, {
326
332
  markdown: true,
@@ -680,6 +686,7 @@ const runTypesCommand = async ({ dir, file, url, token, cwd = process.cwd(), log
680
686
 
681
687
  const USAGE = `Usage: content init [--dir content] [--url origin] [--skip-install]
682
688
  content model <pull|plan|apply> [--file path] [--url origin] [--prune]
689
+ [--lock | --unlock]
683
690
  content types [--dir content] [--file path] [--url origin]
684
691
 
685
692
  init start a site's repository on the token's environment: the
@@ -698,6 +705,9 @@ const USAGE = `Usage: content init [--dir content] [--url origin] [--skip-instal
698
705
  reads it instead of pulling the model
699
706
  --url the CMS (default $CONTENT_URL, else ${config.DEFAULT_URL})
700
707
  --prune plan and apply also delete content types the file leaves out
708
+ --lock apply also marks the environment's model as managed in code:
709
+ read-only in the dashboard, the agent API and MCP
710
+ --unlock apply also gives the model back to the dashboard
701
711
 
702
712
  Needs CONTENT_MANAGEMENT_TOKEN: a management token from Space settings
703
713
  (not for types --file).`;
@@ -717,6 +727,14 @@ const main = async ()=>{
717
727
  type: 'boolean',
718
728
  default: false
719
729
  },
730
+ lock: {
731
+ type: 'boolean',
732
+ default: false
733
+ },
734
+ unlock: {
735
+ type: 'boolean',
736
+ default: false
737
+ },
720
738
  dir: {
721
739
  type: 'string',
722
740
  default: 'content'
@@ -767,12 +785,19 @@ const main = async ()=>{
767
785
  install: !values['skip-install']
768
786
  });
769
787
  }
788
+ if (values.lock && values.unlock) {
789
+ throw new CliError(`Use --lock or --unlock, not both.\n\n${USAGE}`, 2);
790
+ }
791
+ if ((values.lock || values.unlock) && modelCommand !== 'apply') {
792
+ throw new CliError(`--lock and --unlock go with model apply.\n\n${USAGE}`, 2);
793
+ }
770
794
  return runModelCommand({
771
795
  command: modelCommand,
772
796
  file: values.file ?? 'content/content-model.json',
773
797
  url,
774
798
  token,
775
799
  prune: values.prune,
800
+ lock: values.lock ? true : values.unlock ? false : undefined,
776
801
  summaryFile: process.env.GITHUB_STEP_SUMMARY || undefined
777
802
  });
778
803
  };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RichTextFormat, E as Entry, a as RedirectList, b as Redirect, c as EntryList, M as ModelFile, A as Asset, B as Block, I as ImproveBlock, d as EntryStub, e as RichTextNode } from './types-gc2dwaqa.js';
2
- export { C as ContentTypeDefinition, f as ContentTypeKind, g as Environment, F as FieldDefinition, h as FieldType, i as RichTextDocument, j as RichTextMark } from './types-gc2dwaqa.js';
1
+ import { R as RichTextFormat, E as Entry, a as RedirectList, b as Redirect, c as EntryList, M as ModelFile, A as Asset, B as Block, I as ImproveBlock, d as EntryStub, e as RichTextNode } from './types-hmpsikmo.js';
2
+ export { C as ContentTypeDefinition, f as ContentTypeKind, g as Environment, F as FieldDefinition, h as FieldType, i as RichTextDocument, j as RichTextMark } from './types-hmpsikmo.js';
3
3
 
4
4
  type ContentClientOptions = {
5
5
  token: string;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RichTextFormat, E as Entry, a as RedirectList, b as Redirect, c as EntryList, M as ModelFile, A as Asset, B as Block, I as ImproveBlock, d as EntryStub, e as RichTextNode } from './types-gc2dwaqa.js';
2
- export { C as ContentTypeDefinition, f as ContentTypeKind, g as Environment, F as FieldDefinition, h as FieldType, i as RichTextDocument, j as RichTextMark } from './types-gc2dwaqa.js';
1
+ import { R as RichTextFormat, E as Entry, a as RedirectList, b as Redirect, c as EntryList, M as ModelFile, A as Asset, B as Block, I as ImproveBlock, d as EntryStub, e as RichTextNode } from './types-hmpsikmo.js';
2
+ export { C as ContentTypeDefinition, f as ContentTypeKind, g as Environment, F as FieldDefinition, h as FieldType, i as RichTextDocument, j as RichTextMark } from './types-hmpsikmo.js';
3
3
 
4
4
  type ContentClientOptions = {
5
5
  token: string;
@@ -84,10 +84,15 @@ type FieldDefinition = BaseField & ({
84
84
  minLength?: number;
85
85
  maxLength?: number;
86
86
  pattern?: string;
87
+ format?: 'url' | 'email' | 'color' | 'slug';
88
+ unique?: boolean;
89
+ defaultValue?: string;
87
90
  } | {
88
91
  type: 'textarea';
89
92
  minLength?: number;
90
93
  maxLength?: number;
94
+ pattern?: string;
95
+ defaultValue?: string;
91
96
  } | {
92
97
  type: 'richtext';
93
98
  } | {
@@ -95,8 +100,11 @@ type FieldDefinition = BaseField & ({
95
100
  integer?: boolean;
96
101
  min?: number;
97
102
  max?: number;
103
+ unique?: boolean;
104
+ defaultValue?: number;
98
105
  } | {
99
106
  type: 'boolean';
107
+ defaultValue?: boolean;
100
108
  } | {
101
109
  type: 'datetime';
102
110
  withTime?: boolean;
@@ -107,14 +115,19 @@ type FieldDefinition = BaseField & ({
107
115
  value: string;
108
116
  label: string;
109
117
  }[];
118
+ defaultValue?: string | string[];
110
119
  } | {
111
120
  type: 'asset';
112
121
  multiple?: boolean;
113
122
  mimeTypes?: string[];
123
+ min?: number;
124
+ max?: number;
114
125
  } | {
115
126
  type: 'reference';
116
127
  multiple?: boolean;
117
128
  contentTypes?: string[];
129
+ min?: number;
130
+ max?: number;
118
131
  } | {
119
132
  type: 'blocks';
120
133
  allowedBlocks?: string[];
@@ -138,4 +151,4 @@ type ModelFile = {
138
151
  };
139
152
 
140
153
  export type { Asset as A, Block as B, ContentTypeDefinition as C, Entry as E, FieldDefinition as F, ImproveBlock as I, ModelFile as M, RichTextFormat as R, RedirectList as a, Redirect as b, EntryList as c, EntryStub as d, RichTextNode as e, ContentTypeKind as f, Environment as g, FieldType as h, RichTextDocument as i, RichTextMark as j };
141
- //# sourceMappingURL=types-gc2dwaqa.d.ts.map
154
+ //# sourceMappingURL=types-hmpsikmo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-gc2dwaqa.d.ts","sources":["../src/types.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,KAAK,cAAc;AACnB,KAAK,KAAK;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B,kBAAkB,MAAM;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS;AACd;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA,KAAK,YAAY,gBAAgB,KAAK,GAAG,KAAK,IAAI,KAAK;AACvD;AACA;AACA,cAAc,MAAM;AACpB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB,cAAc,YAAY;AAC1B;AACA,YAAY,YAAY;AACxB;AACA,KAAK,gBAAgB,GAAG,YAAY;AACpC;AACA;AACA,KAAK,SAAS,gBAAgB,KAAK,GAAG,KAAK;AAC3C;AACA;AACA;AACA;AACA;AACA,KAAK,QAAQ;AACb;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA,KAAK,eAAe;AACpB,KAAK,SAAS;AACd;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,eAAe,GAAG,SAAS;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS,GAAG,eAAe;AAChC,KAAK,qBAAqB;AAC1B;AACA;AACA,UAAU,eAAe;AACzB;AACA,YAAY,eAAe;AAC3B;AACA,KAAK,SAAS;AACd;AACA;AACA,kBAAkB,qBAAqB;AACvC;;","names":[]}
1
+ {"version":3,"file":"types-hmpsikmo.d.ts","sources":["../src/types.ts"],"mappings":"AAAA,KAAK,WAAW;AAChB,KAAK,cAAc;AACnB,KAAK,KAAK;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oBAAoB,MAAM;AAC1B,kBAAkB,MAAM;AACxB;AACA;AACA;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA;AACA;AACA,WAAW,MAAM;AACjB;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS;AACd;AACA;AACA;AACA,KAAK,KAAK,iBAAiB,MAAM,oBAAoB,MAAM;AAC3D;AACA;AACA;AACA,KAAK,YAAY,gBAAgB,KAAK,GAAG,KAAK,IAAI,KAAK;AACvD;AACA;AACA,cAAc,MAAM;AACpB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB;AACA,KAAK,YAAY;AACjB;AACA,YAAY,MAAM;AAClB,cAAc,YAAY;AAC1B;AACA,YAAY,YAAY;AACxB;AACA,KAAK,gBAAgB,GAAG,YAAY;AACpC;AACA;AACA,KAAK,SAAS,gBAAgB,KAAK,GAAG,KAAK;AAC3C;AACA;AACA;AACA;AACA;AACA,KAAK,QAAQ;AACb;AACA;AACA;AACA;AACA,KAAK,YAAY;AACjB,WAAW,QAAQ;AACnB;AACA;AACA;AACA;AACA,KAAK,eAAe;AACpB,KAAK,SAAS;AACd;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,eAAe,GAAG,SAAS;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK,SAAS,GAAG,eAAe;AAChC,KAAK,qBAAqB;AAC1B;AACA;AACA,UAAU,eAAe;AACzB;AACA,YAAY,eAAe;AAC3B;AACA,KAAK,SAAS;AACd;AACA;AACA,kBAAkB,qBAAqB;AACvC;;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@obelism/content",
3
3
  "description": "Obelism Content SDK: the delivery API client, the visual editor bridge with prompt editing, editing on your own site, webhook verification, and the content model CLI",
4
- "version": "0.10.0",
4
+ "version": "0.12.0",
5
5
  "keywords": [
6
6
  "cms",
7
7
  "headless-cms",