cogens 0.2.0 → 0.3.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 (158) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +35 -7
  3. package/dist/admin/app.d.ts +21 -0
  4. package/dist/admin/app.d.ts.map +1 -0
  5. package/dist/admin/app.js +702 -0
  6. package/dist/admin/app.js.map +1 -0
  7. package/dist/admin/assets.d.ts +17 -0
  8. package/dist/admin/assets.d.ts.map +1 -0
  9. package/dist/admin/assets.js +51 -0
  10. package/dist/admin/assets.js.map +1 -0
  11. package/dist/admin/fields.d.ts +29 -0
  12. package/dist/admin/fields.d.ts.map +1 -0
  13. package/dist/admin/fields.js +130 -0
  14. package/dist/admin/fields.js.map +1 -0
  15. package/dist/admin/forms.d.ts +18 -0
  16. package/dist/admin/forms.d.ts.map +1 -0
  17. package/dist/admin/forms.js +53 -0
  18. package/dist/admin/forms.js.map +1 -0
  19. package/dist/admin/index.d.ts +15 -0
  20. package/dist/admin/index.d.ts.map +1 -0
  21. package/dist/admin/index.js +13 -0
  22. package/dist/admin/index.js.map +1 -0
  23. package/dist/admin/rules.d.ts +24 -0
  24. package/dist/admin/rules.d.ts.map +1 -0
  25. package/dist/admin/rules.js +51 -0
  26. package/dist/admin/rules.js.map +1 -0
  27. package/dist/admin/types.d.ts +147 -0
  28. package/dist/admin/types.d.ts.map +1 -0
  29. package/dist/admin/types.js +2 -0
  30. package/dist/admin/types.js.map +1 -0
  31. package/dist/admin/views.d.ts +138 -0
  32. package/dist/admin/views.d.ts.map +1 -0
  33. package/dist/admin/views.js +225 -0
  34. package/dist/admin/views.js.map +1 -0
  35. package/dist/auth/handoff.d.ts +27 -0
  36. package/dist/auth/handoff.d.ts.map +1 -0
  37. package/dist/auth/handoff.js +41 -0
  38. package/dist/auth/handoff.js.map +1 -0
  39. package/dist/auth/index.d.ts +10 -0
  40. package/dist/auth/index.d.ts.map +1 -0
  41. package/dist/auth/index.js +10 -0
  42. package/dist/auth/index.js.map +1 -0
  43. package/dist/auth/password.d.ts +48 -0
  44. package/dist/auth/password.d.ts.map +1 -0
  45. package/dist/auth/password.js +154 -0
  46. package/dist/auth/password.js.map +1 -0
  47. package/dist/auth/principal.d.ts +30 -0
  48. package/dist/auth/principal.d.ts.map +1 -0
  49. package/dist/auth/principal.js +30 -0
  50. package/dist/auth/principal.js.map +1 -0
  51. package/dist/auth/session.d.ts +68 -0
  52. package/dist/auth/session.d.ts.map +1 -0
  53. package/dist/auth/session.js +92 -0
  54. package/dist/auth/session.js.map +1 -0
  55. package/dist/core/access/ability.d.ts +24 -0
  56. package/dist/core/access/ability.d.ts.map +1 -0
  57. package/dist/core/access/ability.js +64 -0
  58. package/dist/core/access/ability.js.map +1 -0
  59. package/dist/core/access/can.d.ts +41 -0
  60. package/dist/core/access/can.d.ts.map +1 -0
  61. package/dist/core/access/can.js +38 -0
  62. package/dist/core/access/can.js.map +1 -0
  63. package/dist/core/access/compile.d.ts +12 -0
  64. package/dist/core/access/compile.d.ts.map +1 -0
  65. package/dist/core/access/compile.js +53 -0
  66. package/dist/core/access/compile.js.map +1 -0
  67. package/dist/core/access/permits.d.ts +24 -0
  68. package/dist/core/access/permits.d.ts.map +1 -0
  69. package/dist/core/access/permits.js +29 -0
  70. package/dist/core/access/permits.js.map +1 -0
  71. package/dist/core/access/when.d.ts +6 -0
  72. package/dist/core/access/when.d.ts.map +1 -0
  73. package/dist/core/access/when.js +64 -0
  74. package/dist/core/access/when.js.map +1 -0
  75. package/dist/core/access/where.d.ts +25 -0
  76. package/dist/core/access/where.d.ts.map +1 -0
  77. package/dist/core/access/where.js +81 -0
  78. package/dist/core/access/where.js.map +1 -0
  79. package/dist/core/columns.d.ts +6 -0
  80. package/dist/core/columns.d.ts.map +1 -0
  81. package/dist/core/columns.js +6 -0
  82. package/dist/core/columns.js.map +1 -0
  83. package/dist/core/config/define.d.ts +101 -0
  84. package/dist/core/config/define.d.ts.map +1 -0
  85. package/dist/core/config/define.js +97 -0
  86. package/dist/core/config/define.js.map +1 -0
  87. package/dist/core/config/field.d.ts +87 -0
  88. package/dist/core/config/field.d.ts.map +1 -0
  89. package/dist/core/config/field.js +75 -0
  90. package/dist/core/config/field.js.map +1 -0
  91. package/dist/core/errors.d.ts +66 -0
  92. package/dist/core/errors.d.ts.map +1 -0
  93. package/dist/core/errors.js +94 -0
  94. package/dist/core/errors.js.map +1 -0
  95. package/dist/core/index.d.ts +31 -0
  96. package/dist/core/index.d.ts.map +1 -0
  97. package/dist/core/index.js +20 -0
  98. package/dist/core/index.js.map +1 -0
  99. package/dist/core/media/index.d.ts +36 -0
  100. package/dist/core/media/index.d.ts.map +1 -0
  101. package/dist/core/media/index.js +99 -0
  102. package/dist/core/media/index.js.map +1 -0
  103. package/dist/core/principal.d.ts +28 -0
  104. package/dist/core/principal.d.ts.map +1 -0
  105. package/dist/core/principal.js +25 -0
  106. package/dist/core/principal.js.map +1 -0
  107. package/dist/core/store/assets.d.ts +3 -0
  108. package/dist/core/store/assets.d.ts.map +1 -0
  109. package/dist/core/store/assets.js +3 -0
  110. package/dist/core/store/assets.js.map +1 -0
  111. package/dist/core/store/cms.d.ts +53 -0
  112. package/dist/core/store/cms.d.ts.map +1 -0
  113. package/dist/core/store/cms.js +154 -0
  114. package/dist/core/store/cms.js.map +1 -0
  115. package/dist/core/store/content.d.ts +57 -0
  116. package/dist/core/store/content.d.ts.map +1 -0
  117. package/dist/core/store/content.js +455 -0
  118. package/dist/core/store/content.js.map +1 -0
  119. package/dist/core/store/sql.d.ts +88 -0
  120. package/dist/core/store/sql.d.ts.map +1 -0
  121. package/dist/core/store/sql.js +149 -0
  122. package/dist/core/store/sql.js.map +1 -0
  123. package/dist/core/store/types.d.ts +107 -0
  124. package/dist/core/store/types.d.ts.map +1 -0
  125. package/dist/core/store/types.js +2 -0
  126. package/dist/core/store/types.js.map +1 -0
  127. package/dist/core/testing/index.d.ts +27 -0
  128. package/dist/core/testing/index.d.ts.map +1 -0
  129. package/dist/core/testing/index.js +60 -0
  130. package/dist/core/testing/index.js.map +1 -0
  131. package/dist/migrations-tool/bin.d.ts +3 -0
  132. package/dist/migrations-tool/bin.d.ts.map +1 -0
  133. package/dist/migrations-tool/bin.js +40 -0
  134. package/dist/migrations-tool/bin.js.map +1 -0
  135. package/dist/migrations-tool/index.d.ts +16 -0
  136. package/dist/migrations-tool/index.d.ts.map +1 -0
  137. package/dist/migrations-tool/index.js +24 -0
  138. package/dist/migrations-tool/index.js.map +1 -0
  139. package/dist/testing/db.d.ts +16 -0
  140. package/dist/testing/db.d.ts.map +1 -0
  141. package/dist/testing/db.js +43 -0
  142. package/dist/testing/db.js.map +1 -0
  143. package/dist/testing/index.d.ts +10 -0
  144. package/dist/testing/index.d.ts.map +1 -0
  145. package/dist/testing/index.js +8 -0
  146. package/dist/testing/index.js.map +1 -0
  147. package/package.json +33 -11
  148. package/src/admin/app.ts +181 -36
  149. package/src/admin/fields.ts +5 -2
  150. package/src/admin/index.ts +3 -2
  151. package/src/admin/types.ts +52 -1
  152. package/src/admin/views.ts +99 -21
  153. package/src/core/config/define.ts +1 -1
  154. package/src/core/config/field.ts +19 -2
  155. package/src/core/index.ts +1 -1
  156. package/src/core/store/cms.ts +1 -1
  157. package/src/migrations-tool/bin.ts +34 -0
  158. package/{scripts/print-migration.ts → src/migrations-tool/index.ts} +6 -19
@@ -0,0 +1,101 @@
1
+ import type { AccessFn } from '../access/can.ts';
2
+ import type { AfterWriteContext, WriteContext } from '../store/types.ts';
3
+ import { FieldBuilder, type FieldMeta } from './field.ts';
4
+ export interface GroupConfig {
5
+ groupId: string;
6
+ name: string;
7
+ helpText?: string;
8
+ collapsed?: boolean;
9
+ fields: Record<string, FieldBuilder<any, any>>;
10
+ }
11
+ export declare function group(opts: {
12
+ id: string;
13
+ name: string;
14
+ helpText?: string;
15
+ collapsed?: boolean;
16
+ fields: Record<string, FieldBuilder<any, any>>;
17
+ }): GroupConfig;
18
+ /** An action the admin offers on one entry of an external collection. */
19
+ export interface ServiceAction {
20
+ id: string;
21
+ label: string;
22
+ /** The confirmation text shown before the action runs. */
23
+ confirm: string;
24
+ method: 'POST' | 'DELETE';
25
+ /** Path template; `:id` is the entry's id. */
26
+ path: string;
27
+ /** A content type to pick an entry of first; the body sent is `{ from: <this id>, into: <picked id> }`. */
28
+ target?: string;
29
+ destructive?: boolean;
30
+ }
31
+ /** An external collection: a read-only view over a table of the host's own, never stored as entries. */
32
+ export interface ServiceConfig {
33
+ readOnly: true;
34
+ actions?: ServiceAction[];
35
+ }
36
+ /** Names a column or a condition keyword may not be used as a field name for. */
37
+ export declare const RESERVED_FIELD_NAMES: readonly ["id", "type", "content_type", "owner_id", "slug", "status", "parent_id", "parent_status", "sort_key", "publish_at", "created_at", "updated_at", "data", "and", "or", "in"];
38
+ export type Fields = Record<string, FieldBuilder<any, any>>;
39
+ export interface ContentType<F extends Fields = Fields> {
40
+ readonly id: string;
41
+ readonly name: string;
42
+ readonly displayField: string;
43
+ readonly singleton?: boolean;
44
+ /** Entries have an owner; the type must then have an `access` function. */
45
+ readonly owned: boolean;
46
+ /** Fields conditions may name; each becomes a generated column (cogens-print-migration prints it). */
47
+ readonly indexed: readonly string[];
48
+ /** The slug is unique among this type's entries. */
49
+ readonly uniqueSlug: boolean;
50
+ /** The id of the type this type's entries are children of (`parent_id` names the entry). */
51
+ readonly parent?: string;
52
+ /** What a child copies from its parent in the same write that changes it. */
53
+ readonly mirrors: readonly 'status'[];
54
+ readonly access?: AccessFn<any>;
55
+ readonly beforeWrite?: (context: WriteContext<any>) => void | Promise<void>;
56
+ readonly afterWrite?: (context: AfterWriteContext<any>) => void | Promise<void>;
57
+ readonly service?: ServiceConfig;
58
+ /** Every field, flat. */
59
+ readonly fields: F;
60
+ readonly fieldMeta: Record<string, FieldMeta>;
61
+ readonly groups: GroupConfig[];
62
+ /** The fields of a type declared without groups. */
63
+ readonly flatFields: Fields;
64
+ }
65
+ export interface ContentTypeOptions<F extends Fields | GroupConfig[]> {
66
+ id: string;
67
+ name: string;
68
+ displayField: string;
69
+ singleton?: boolean;
70
+ owned?: boolean;
71
+ indexed?: readonly string[];
72
+ uniqueSlug?: boolean;
73
+ parent?: string;
74
+ mirrors?: readonly 'status'[];
75
+ access?: AccessFn<any>;
76
+ beforeWrite?: (context: WriteContext<any>) => void | Promise<void>;
77
+ afterWrite?: (context: AfterWriteContext<any>) => void | Promise<void>;
78
+ service?: ServiceConfig;
79
+ fields: F;
80
+ }
81
+ export declare function contentType<F extends Fields | GroupConfig[]>(opts: ContentTypeOptions<F>): ContentType<F extends GroupConfig[] ? Fields : Extract<F, Fields>>;
82
+ export interface CmsConfig {
83
+ siteName: string;
84
+ contentTypes: ContentType<any>[];
85
+ }
86
+ export declare function defineConfig(config: CmsConfig): CmsConfig;
87
+ type Flatten<T> = {
88
+ [K in keyof T]: T[K];
89
+ } & {};
90
+ type RequiredKeys<F extends Fields> = {
91
+ [K in keyof F]: F[K] extends FieldBuilder<any, true> ? K : never;
92
+ }[keyof F];
93
+ type OptionalKeys<F extends Fields> = Exclude<keyof F, RequiredKeys<F>>;
94
+ /** The type of an entry's `data`: required fields present, the rest optional. */
95
+ export type Infer<T extends ContentType<any>> = T extends ContentType<infer F> ? Flatten<{
96
+ [K in RequiredKeys<F>]: F[K]['_type'];
97
+ } & {
98
+ [K in OptionalKeys<F>]?: F[K]['_type'] | null;
99
+ }> : never;
100
+ export {};
101
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../../src/core/config/define.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,OAAO,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,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACpH,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAExE,iFAAiF;AACjF,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,CAAC,IAC1C,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAC1B,OAAO,CAAC;KAAG,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,IAAI;CAAE,CAAC,GACtG,KAAK,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * contentType, group, defineConfig, Infer: the schema definition API. A type
3
+ * names its fields and, beyond Koguma's, whether its entries are owned, which
4
+ * fields are indexed, who may do what (`access`), what a child mirrors of its
5
+ * parent, and hooks around writes.
6
+ */
7
+ import { ConfigError } from "../errors.js";
8
+ import { FieldBuilder } from "./field.js";
9
+ export function group(opts) {
10
+ return { groupId: opts.id, name: opts.name, helpText: opts.helpText, collapsed: opts.collapsed, fields: opts.fields };
11
+ }
12
+ /** Names a column or a condition keyword may not be used as a field name for. */
13
+ export const RESERVED_FIELD_NAMES = [
14
+ 'id',
15
+ 'type',
16
+ 'content_type',
17
+ 'owner_id',
18
+ 'slug',
19
+ 'status',
20
+ 'parent_id',
21
+ 'parent_status',
22
+ 'sort_key',
23
+ 'publish_at',
24
+ 'created_at',
25
+ 'updated_at',
26
+ 'data',
27
+ 'and',
28
+ 'or',
29
+ 'in'
30
+ ];
31
+ const FIELD_NAME = /^[A-Za-z][A-Za-z0-9_]*$/;
32
+ const TYPE_ID = /^[a-z][A-Za-z0-9_-]*$/;
33
+ export function contentType(opts) {
34
+ if (!TYPE_ID.test(opts.id))
35
+ throw new ConfigError(`Type id "${opts.id}" must start with a lowercase letter and use letters, digits, - and _.`, opts.id);
36
+ const all = {};
37
+ const groups = [];
38
+ let flatFields = {};
39
+ if (Array.isArray(opts.fields)) {
40
+ for (const g of opts.fields) {
41
+ groups.push(g);
42
+ Object.assign(all, g.fields);
43
+ }
44
+ }
45
+ else {
46
+ flatFields = opts.fields;
47
+ Object.assign(all, flatFields);
48
+ }
49
+ for (const name of Object.keys(all)) {
50
+ if (RESERVED_FIELD_NAMES.includes(name)) {
51
+ throw new ConfigError(`Field "${name}" of type "${opts.id}" collides with a built-in name (${RESERVED_FIELD_NAMES.join(', ')}); the built-in column of that name is used instead.`, opts.id, name);
52
+ }
53
+ if (!FIELD_NAME.test(name)) {
54
+ throw new ConfigError(`Field "${name}" of type "${opts.id}" must start with a letter and use letters, digits and _.`, opts.id, name);
55
+ }
56
+ }
57
+ const indexed = opts.indexed ?? [];
58
+ for (const name of indexed) {
59
+ if (!(name in all))
60
+ throw new ConfigError(`Type "${opts.id}" indexes "${name}", which is not one of its fields.`, opts.id, name);
61
+ }
62
+ if (new Set(indexed).size !== indexed.length) {
63
+ throw new ConfigError(`Type "${opts.id}" lists an indexed field twice.`, opts.id);
64
+ }
65
+ if (opts.mirrors?.length && opts.parent === undefined) {
66
+ throw new ConfigError(`Type "${opts.id}" mirrors its parent's status but names no parent.`, opts.id);
67
+ }
68
+ if (opts.displayField !== undefined && !(opts.displayField in all) && Object.keys(all).length > 0) {
69
+ throw new ConfigError(`Type "${opts.id}" shows "${opts.displayField}", which is not one of its fields.`, opts.id, opts.displayField);
70
+ }
71
+ const fieldMeta = {};
72
+ for (const [name, builder] of Object.entries(all))
73
+ fieldMeta[name] = builder.meta;
74
+ return {
75
+ id: opts.id,
76
+ name: opts.name,
77
+ displayField: opts.displayField,
78
+ singleton: opts.singleton,
79
+ owned: opts.owned ?? false,
80
+ indexed,
81
+ uniqueSlug: opts.uniqueSlug ?? false,
82
+ parent: opts.parent,
83
+ mirrors: opts.mirrors ?? [],
84
+ access: opts.access,
85
+ beforeWrite: opts.beforeWrite,
86
+ afterWrite: opts.afterWrite,
87
+ service: opts.service,
88
+ fields: all,
89
+ fieldMeta,
90
+ groups,
91
+ flatFields
92
+ };
93
+ }
94
+ export function defineConfig(config) {
95
+ return config;
96
+ }
97
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/core/config/define.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAU1D,MAAM,UAAU,KAAK,CAAC,IAMrB;IACC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACxH,CAAC;AAsBD,iFAAiF;AACjF,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI;IACJ,MAAM;IACN,cAAc;IACd,UAAU;IACV,MAAM;IACN,QAAQ;IACR,WAAW;IACX,eAAe;IACf,UAAU;IACV,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,MAAM;IACN,KAAK;IACL,IAAI;IACJ,IAAI;CACI,CAAC;AAEX,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAC7C,MAAM,OAAO,GAAG,uBAAuB,CAAC;AAgDxC,MAAM,UAAU,WAAW,CACzB,IAA2B;IAE3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,YAAY,IAAI,CAA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AS;QACzB,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK;QAC1B,OAAO;QACP,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK;QACpC,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;QAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,MAAM,EAAE,GAAY;QACpB,SAAS;QACT,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC;AAOD,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * field.* builders: the content fields of a type. Each holds its label, its kind
3
+ * for the admin and a JSON Schema (draft 7) for @cfworker/json-schema, which
4
+ * validates without `new Function`, so it runs in a Worker.
5
+ *
6
+ * field.text('Title').required().max(100)
7
+ * field.number('Revision').system()
8
+ */
9
+ import type { Schema } from '@cfworker/json-schema';
10
+ export type FieldType = 'text' | 'longText' | 'markdown' | 'url' | 'email' | 'boolean' | 'number' | 'date' | 'select' | 'reference' | 'references' | 'files' | 'json';
11
+ export interface FieldMeta {
12
+ label: string;
13
+ fieldType: FieldType;
14
+ required: boolean;
15
+ /** A system field is writable only by a caller whose rule lists it by name. */
16
+ system: boolean;
17
+ refContentType?: string;
18
+ /** A select's stored values, in order. */
19
+ options?: string[];
20
+ /** A select's label for each value that has one; a value with none is shown as itself. */
21
+ optionLabels?: Record<string, string>;
22
+ /** Stored when a create leaves the field out; set by the store, so a system field may have one. */
23
+ default?: unknown;
24
+ }
25
+ /** `T` is the stored value's type and `R` whether the field is required (a phantom, for `Infer`). */
26
+ export declare class FieldBuilder<T = unknown, R extends boolean = false> {
27
+ readonly meta: FieldMeta;
28
+ readonly schema: Schema;
29
+ readonly _type: T;
30
+ readonly _required: R;
31
+ constructor(meta: FieldMeta, schema: Schema);
32
+ /** The value must be present on create (an update may leave it out). */
33
+ required(): FieldBuilder<T, true>;
34
+ /** Writable only by a caller whose rule lists the field by name. */
35
+ system(): FieldBuilder<T, R>;
36
+ /**
37
+ * The value a create stores when the field is left out. The store applies it whoever creates, so a system field
38
+ * the creator may not write (a flag a rule reads, such as `retired: 0`) still starts with a value.
39
+ */
40
+ default(value: T): FieldBuilder<T, R>;
41
+ /** Maximum length (text), value (number) or count (list). */
42
+ max(value: number): FieldBuilder<T, R>;
43
+ /** Minimum length (text), value (number) or count (list). */
44
+ min(value: number): FieldBuilder<T, R>;
45
+ }
46
+ export interface StoredFile {
47
+ name: string;
48
+ size: number;
49
+ url: string;
50
+ }
51
+ /** A select's option: its stored value, or the value with the label the admin shows for it. */
52
+ export type SelectOption = string | {
53
+ readonly value: string;
54
+ readonly label: string;
55
+ };
56
+ type OptionValue<O> = O extends string ? O : O extends {
57
+ readonly value: infer V extends string;
58
+ } ? V : never;
59
+ export declare const field: {
60
+ text: (label: string) => FieldBuilder<string, false>;
61
+ longText: (label: string) => FieldBuilder<string, false>;
62
+ /** Markdown, stored as a string. */
63
+ markdown: (label: string) => FieldBuilder<string, false>;
64
+ url: (label: string) => FieldBuilder<string, false>;
65
+ email: (label: string) => FieldBuilder<string, false>;
66
+ boolean: (label: string) => FieldBuilder<boolean, false>;
67
+ number: (label: string) => FieldBuilder<number, false>;
68
+ /** An ISO 8601 date and time. */
69
+ date: (label: string) => FieldBuilder<string, false>;
70
+ /**
71
+ * One of a fixed list. An option is its stored value, or `{ value, label }`: the admin shows and offers the label
72
+ * and stores the value.
73
+ */
74
+ select: <const O extends readonly SelectOption[]>(label: string, opts: {
75
+ options: O;
76
+ }) => FieldBuilder<OptionValue<O[number]>, false>;
77
+ /** The id of an entry of another type. */
78
+ ref: (contentType: string, label: string) => FieldBuilder<string, false>;
79
+ /** Ids of entries of another type, in order. */
80
+ refs: (contentType: string, label: string) => FieldBuilder<string[], false>;
81
+ /** A read-only list of stored files, `{ name, size, url }` each. */
82
+ files: (label: string) => FieldBuilder<StoredFile[], false>;
83
+ /** Any JSON value. */
84
+ json: <T = unknown>(label: string) => FieldBuilder<T, false>;
85
+ };
86
+ export {};
87
+ //# sourceMappingURL=field.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../src/core/config/field.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,UAAU,GACV,UAAU,GACV,KAAK,GACL,OAAO,GACP,SAAS,GACT,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,+EAA+E;IAC/E,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0FAA0F;IAC1F,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,mGAAmG;IACnG,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qGAAqG;AACrG,qBAAa,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK;IAK5D,QAAQ,CAAC,IAAI,EAAE,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM;IALzB,SAAiB,KAAK,EAAE,CAAC,CAAC;IAC1B,SAAiB,SAAS,EAAE,CAAC,CAAC;gBAGnB,IAAI,EAAE,SAAS,EACf,MAAM,EAAE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M;IAEzC,oEAAoE;mBACrD,MAAM;IASrB,sBAAsB;WACf,CAAC,mBAAmB,MAAM;CAClC,CAAC"}
@@ -0,0 +1,75 @@
1
+ /** `T` is the stored value's type and `R` whether the field is required (a phantom, for `Infer`). */
2
+ export class FieldBuilder {
3
+ meta;
4
+ schema;
5
+ constructor(meta, schema) {
6
+ this.meta = meta;
7
+ this.schema = schema;
8
+ }
9
+ /** The value must be present on create (an update may leave it out). */
10
+ required() {
11
+ return new FieldBuilder({ ...this.meta, required: true }, this.schema);
12
+ }
13
+ /** Writable only by a caller whose rule lists the field by name. */
14
+ system() {
15
+ return new FieldBuilder({ ...this.meta, system: true }, this.schema);
16
+ }
17
+ /**
18
+ * The value a create stores when the field is left out. The store applies it whoever creates, so a system field
19
+ * the creator may not write (a flag a rule reads, such as `retired: 0`) still starts with a value.
20
+ */
21
+ default(value) {
22
+ return new FieldBuilder({ ...this.meta, default: value }, this.schema);
23
+ }
24
+ /** Maximum length (text), value (number) or count (list). */
25
+ max(value) {
26
+ const key = this.schema.type === 'string' ? 'maxLength' : this.schema.type === 'number' ? 'maximum' : 'maxItems';
27
+ return new FieldBuilder(this.meta, { ...this.schema, [key]: value });
28
+ }
29
+ /** Minimum length (text), value (number) or count (list). */
30
+ min(value) {
31
+ const key = this.schema.type === 'string' ? 'minLength' : this.schema.type === 'number' ? 'minimum' : 'minItems';
32
+ return new FieldBuilder(this.meta, { ...this.schema, [key]: value });
33
+ }
34
+ }
35
+ const make = (label, fieldType, schema, extra = {}) => new FieldBuilder({ label, fieldType, required: false, system: false, ...extra }, schema);
36
+ export const field = {
37
+ text: (label) => make(label, 'text', { type: 'string' }),
38
+ longText: (label) => make(label, 'longText', { type: 'string' }),
39
+ /** Markdown, stored as a string. */
40
+ markdown: (label) => make(label, 'markdown', { type: 'string' }),
41
+ url: (label) => make(label, 'url', { type: 'string', format: 'uri' }),
42
+ email: (label) => make(label, 'email', { type: 'string', format: 'email' }),
43
+ boolean: (label) => make(label, 'boolean', { type: 'boolean' }),
44
+ number: (label) => make(label, 'number', { type: 'number' }),
45
+ /** An ISO 8601 date and time. */
46
+ date: (label) => make(label, 'date', { type: 'string', format: 'date-time' }),
47
+ /**
48
+ * One of a fixed list. An option is its stored value, or `{ value, label }`: the admin shows and offers the label
49
+ * and stores the value.
50
+ */
51
+ select: (label, opts) => {
52
+ const values = opts.options.map(o => (typeof o === 'string' ? o : o.value));
53
+ const labelled = opts.options.filter((o) => typeof o !== 'string');
54
+ return make(label, 'select', { type: 'string', enum: values }, {
55
+ options: values,
56
+ ...(labelled.length > 0 ? { optionLabels: Object.fromEntries(labelled.map(o => [o.value, o.label])) } : {})
57
+ });
58
+ },
59
+ /** The id of an entry of another type. */
60
+ ref: (contentType, label) => make(label, 'reference', { type: 'string' }, { refContentType: contentType }),
61
+ /** Ids of entries of another type, in order. */
62
+ refs: (contentType, label) => make(label, 'references', { type: 'array', items: { type: 'string' } }, { refContentType: contentType }),
63
+ /** A read-only list of stored files, `{ name, size, url }` each. */
64
+ files: (label) => make(label, 'files', {
65
+ type: 'array',
66
+ items: {
67
+ type: 'object',
68
+ properties: { name: { type: 'string' }, size: { type: 'number' }, url: { type: 'string' } },
69
+ required: ['name', 'size', 'url']
70
+ }
71
+ }),
72
+ /** Any JSON value. */
73
+ json: (label) => make(label, 'json', {})
74
+ };
75
+ //# sourceMappingURL=field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field.js","sourceRoot":"","sources":["../../../src/core/config/field.ts"],"names":[],"mappings":"AAwCA,qGAAqG;AACrG,MAAM,OAAO,YAAY;IAKZ;IACA;IAFX,YACW,IAAe,EACf,MAAc;QADd,SAAI,GAAJ,IAAI,CAAW;QACf,WAAM,GAAN,MAAM,CAAQ;IACtB,CAAC;IAEJ,wEAAwE;IACxE,QAAQ;QACN,OAAO,IAAI,YAAY,CAAU,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC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,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC;IACpH,oEAAoE;IACpE,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CACvB,IAAI,CAAe,KAAK,EAAE,OAAO,EAAE;QACjC,IAAI,EAAE,OAAO;QACb,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YAC3F,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC;SAClC;KACF,CAAC;IACJ,sBAAsB;IACtB,IAAI,EAAE,CAAc,KAAa,EAAE,EAAE,CAAC,IAAI,CAAI,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;CACjE,CAAC"}
@@ -0,0 +1,66 @@
1
+ /** The typed errors the store throws. A read the caller may not make never throws; it answers null or an empty list. */
2
+ export type Operation = 'create' | 'read' | 'update' | 'delete' | 'publish';
3
+ /** A write the caller's rules refuse. `field` is set when a field rule caused it. */
4
+ export declare class Forbidden extends Error {
5
+ readonly operation: Operation | 'unpublish';
6
+ readonly type: string;
7
+ readonly field?: string | undefined;
8
+ readonly name = "Forbidden";
9
+ constructor(operation: Operation | 'unpublish', type: string, field?: string | undefined);
10
+ }
11
+ /** The host's configuration is wrong; the message names the type and, where there is one, the field. */
12
+ export declare class ConfigError extends Error {
13
+ readonly type?: string | undefined;
14
+ readonly field?: string | undefined;
15
+ readonly name = "ConfigError";
16
+ constructor(message: string, type?: string | undefined, field?: string | undefined);
17
+ }
18
+ /** A condition the compiler refuses: an unknown operator, a field that is not indexed, or too many values. */
19
+ export declare class ConditionError extends Error {
20
+ readonly field?: string | undefined;
21
+ readonly name = "ConditionError";
22
+ constructor(message: string, field?: string | undefined);
23
+ }
24
+ /** The data does not fit the type's fields, or names a field the type does not have. */
25
+ export declare class ValidationError extends Error {
26
+ readonly type: string;
27
+ readonly issues: {
28
+ field: string;
29
+ message: string;
30
+ }[];
31
+ readonly name = "ValidationError";
32
+ constructor(type: string, issues: {
33
+ field: string;
34
+ message: string;
35
+ }[]);
36
+ }
37
+ /** A before-write hook refused the write. */
38
+ export declare class WriteRefused extends Error {
39
+ readonly type: string;
40
+ readonly name = "WriteRefused";
41
+ constructor(type: string, message: string);
42
+ }
43
+ /** A unique constraint (the id, or a unique slug) was already taken. */
44
+ export declare class Conflict extends Error {
45
+ readonly type: string;
46
+ readonly field: 'id' | 'slug';
47
+ readonly name = "Conflict";
48
+ constructor(type: string, field: 'id' | 'slug');
49
+ }
50
+ /** Publishing a parent would update more children than one atomic write may. */
51
+ export declare class TooManyChildren extends Error {
52
+ readonly type: string;
53
+ readonly count: number;
54
+ readonly limit: number;
55
+ readonly name = "TooManyChildren";
56
+ constructor(type: string, count: number, limit: number);
57
+ }
58
+ /** A bulk write names more entries than one write may hold. */
59
+ export declare class TooManyEntries extends Error {
60
+ readonly type: string;
61
+ readonly count: number;
62
+ readonly limit: number;
63
+ readonly name = "TooManyEntries";
64
+ constructor(type: string, count: number, limit: number);
65
+ }
66
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAExH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE5E,qFAAqF;AACrF,qBAAa,SAAU,SAAQ,KAAK;IAGhC,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM;IAJzB,SAAkB,IAAI,eAAe;gBAE1B,SAAS,EAAE,SAAS,GAAG,WAA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AK,EAAE,IAAI,GAAG,MAAM;CAIhC;AAED,gFAAgF;AAChF,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAJxB,SAAkB,IAAI,qBAAqB;gBAEhC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;CAIzB;AAED,+DAA+D;AAC/D,qBAAa,cAAe,SAAQ,KAAK;IAGrC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAJxB,SAAkB,IAAI,oBAAoB;gBAE/B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM;CAIzB"}
@@ -0,0 +1,94 @@
1
+ /** The typed errors the store throws. A read the caller may not make never throws; it answers null or an empty list. */
2
+ /** A write the caller's rules refuse. `field` is set when a field rule caused it. */
3
+ export class Forbidden extends Error {
4
+ operation;
5
+ type;
6
+ field;
7
+ name = 'Forbidden';
8
+ constructor(operation, type, field) {
9
+ super(field === undefined
10
+ ? `Forbidden: ${operation} on ${type}.`
11
+ : `Forbidden: ${operation} on ${type} may not write the field "${field}".`);
12
+ this.operation = operation;
13
+ this.type = type;
14
+ this.field = field;
15
+ }
16
+ }
17
+ /** The host's configuration is wrong; the message names the type and, where there is one, the field. */
18
+ export class ConfigError extends Error {
19
+ type;
20
+ field;
21
+ name = 'ConfigError';
22
+ constructor(message, type, field) {
23
+ super(message);
24
+ this.type = type;
25
+ this.field = field;
26
+ }
27
+ }
28
+ /** A condition the compiler refuses: an unknown operator, a field that is not indexed, or too many values. */
29
+ export class ConditionError extends Error {
30
+ field;
31
+ name = 'ConditionError';
32
+ constructor(message, field) {
33
+ super(message);
34
+ this.field = field;
35
+ }
36
+ }
37
+ /** The data does not fit the type's fields, or names a field the type does not have. */
38
+ export class ValidationError extends Error {
39
+ type;
40
+ issues;
41
+ name = 'ValidationError';
42
+ constructor(type, issues) {
43
+ super(`Invalid ${type}: ${issues.map(i => `${i.field}: ${i.message}`).join('; ')}`);
44
+ this.type = type;
45
+ this.issues = issues;
46
+ }
47
+ }
48
+ /** A before-write hook refused the write. */
49
+ export class WriteRefused extends Error {
50
+ type;
51
+ name = 'WriteRefused';
52
+ constructor(type, message) {
53
+ super(message);
54
+ this.type = type;
55
+ }
56
+ }
57
+ /** A unique constraint (the id, or a unique slug) was already taken. */
58
+ export class Conflict extends Error {
59
+ type;
60
+ field;
61
+ name = 'Conflict';
62
+ constructor(type, field) {
63
+ super(`Conflict: a ${type} with this ${field} already exists.`);
64
+ this.type = type;
65
+ this.field = field;
66
+ }
67
+ }
68
+ /** Publishing a parent would update more children than one atomic write may. */
69
+ export class TooManyChildren extends Error {
70
+ type;
71
+ count;
72
+ limit;
73
+ name = 'TooManyChildren';
74
+ constructor(type, count, limit) {
75
+ super(`${type} has ${count} children that mirror its status; the limit for one write is ${limit}. Nothing was changed.`);
76
+ this.type = type;
77
+ this.count = count;
78
+ this.limit = limit;
79
+ }
80
+ }
81
+ /** A bulk write names more entries than one write may hold. */
82
+ export class TooManyEntries extends Error {
83
+ type;
84
+ count;
85
+ limit;
86
+ name = 'TooManyEntries';
87
+ constructor(type, count, limit) {
88
+ super(`${count} ${type} entries in one write; the limit is ${limit}. Nothing was changed.`);
89
+ this.type = type;
90
+ this.count = count;
91
+ this.limit = limit;
92
+ }
93
+ }
94
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,wHAAwH;AAIxH,qFAAqF;AACrF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGvB;IACA;IACA;IAJO,IAAI,GAAG,WAAW,CAAC;IACrC,YACW,SAAkC,EAClC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C;IACxC,YACW,IAAY,EACrB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,SAAI,GAAJ,IAAI,CAAQ;IAIvB,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGtB;IACA;IAHO,IAAI,GAAG,UAAU,CAAC;IACpC,YACW,IAAY,EACZ,KAAoB;QAE7B,KAAK,CAAC,eAAe,IAAI,cAAc,KAAK,kBAAkB,CAAC,CAAC;QAHvD,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAe;IAG/B,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAG7B;IACA;IACA;IAJO,IAAI,GAAG,iBAAiB,CAAC;IAC3C,YACW,IAAY,EACZ,KAAa,EACb,KAAa;QAEtB,KAAK,CAAC,GAAG,IAAI,QAAQ,KAAK,gEAAgE,KAAK,wBAAwB,CAAC,CAAC;QAJhH,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAQ;IAGxB,CAAC;CACF;AAED,+DAA+D;AAC/D,MAAM,OAAO,cAAe,SAAQ,KAAK;IAG5B;IACA;IACA;IAJO,IAAI,GAAG,gBAAgB,CAAC;IAC1C,YACW,IAAY,EACZ,KAAa,EACb,KAAa;QAEtB,KAAK,CAAC,GAAG,KAAK,IAAI,IAAI,uCAAuC,KAAK,wBAAwB,CAAC,CAAC;QAJnF,SAAI,GAAJ,IAAI,CAAQ;QACZ,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAQ;IAGxB,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * cogens: the content store. A content type declares who owns it and who may
3
+ * create, read, update, delete and publish it; every read and write names its
4
+ * caller (`cms.content.as(principal)`), and a read the caller may not make
5
+ * answers as a missing row.
6
+ *
7
+ * Imports nothing of the host's, and nothing but `hono`, `@casl/ability` and
8
+ * `@cfworker/json-schema` (test/boundary.test.ts). No export names a
9
+ * type of the decision engine under `can`.
10
+ */
11
+ export { contentType, defineConfig, group, RESERVED_FIELD_NAMES } from './config/define.ts';
12
+ export type { CmsConfig, ContentType, ContentTypeOptions, Fields, GroupConfig, Infer, ServiceAction, ServiceConfig } from './config/define.ts';
13
+ export { field, FieldBuilder } from './config/field.ts';
14
+ export type { FieldMeta, FieldType, SelectOption, StoredFile } from './config/field.ts';
15
+ export { OPERATIONS } from './access/can.ts';
16
+ export type { AccessContext, AccessFn, Can, Grant, GrantOptions } from './access/can.ts';
17
+ export { MAX_IN_VALUES } from './access/where.ts';
18
+ export type { Scalar, Where } from './access/where.ts';
19
+ export { permits } from './access/permits.ts';
20
+ export type { PackedRules, PackedTypeRules } from './access/permits.ts';
21
+ export { admin, anonymous, system } from './principal.ts';
22
+ export type { AdminPrincipal, AnonymousPrincipal, HostPrincipal, Principal, SystemPrincipal } from './principal.ts';
23
+ export { createCms } from './store/cms.ts';
24
+ export type { Cms, CmsOptions } from './store/cms.ts';
25
+ export type { AfterWriteContext, Compare, ContentApi, CreateInput, Entry, ListOptions, OrderBy, Status, TypeRef, UpdateEachChange, UpdatePatch, UpdateResult, When, WriteContext, WriteOptions } from './store/types.ts';
26
+ export type { Asset, MediaApi, MediaOptions, UploadInput } from './media/index.ts';
27
+ export { ConditionError, ConfigError, Conflict, Forbidden, TooManyChildren, TooManyEntries, ValidationError, WriteRefused } from './errors.ts';
28
+ export type { Operation } from './errors.ts';
29
+ export { policyMatrix, PolicyMismatch } from './testing/index.ts';
30
+ export type { PolicyMatrixOptions, Expectation } from './testing/index.ts';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,E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,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnF,OAAO,EACL,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EACjH,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * cogens: the content store. A content type declares who owns it and who may
3
+ * create, read, update, delete and publish it; every read and write names its
4
+ * caller (`cms.content.as(principal)`), and a read the caller may not make
5
+ * answers as a missing row.
6
+ *
7
+ * Imports nothing of the host's, and nothing but `hono`, `@casl/ability` and
8
+ * `@cfworker/json-schema` (test/boundary.test.ts). No export names a
9
+ * type of the decision engine under `can`.
10
+ */
11
+ export { contentType, defineConfig, group, RESERVED_FIELD_NAMES } from "./config/define.js";
12
+ export { field, FieldBuilder } from "./config/field.js";
13
+ export { OPERATIONS } from "./access/can.js";
14
+ export { MAX_IN_VALUES } from "./access/where.js";
15
+ export { permits } from "./access/permits.js";
16
+ export { admin, anonymous, system } from "./principal.js";
17
+ export { createCms } from "./store/cms.js";
18
+ export { ConditionError, ConfigError, Conflict, Forbidden, TooManyChildren, TooManyEntries, ValidationError, WriteRefused } from "./errors.js";
19
+ export { policyMatrix, PolicyMismatch } from "./testing/index.js";
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAI5F,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAS3C,OAAO,EACL,cAAc,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EACjH,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}