@kitsuden/shared 0.0.0-stage → 0.9.0-beta

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 (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +65 -2
  3. package/dist/admin-registry-contract.d.ts +99 -0
  4. package/dist/admin-registry-contract.d.ts.map +1 -0
  5. package/dist/admin-view.d.ts +123 -0
  6. package/dist/admin-view.d.ts.map +1 -0
  7. package/dist/agent-permission.d.ts +161 -0
  8. package/dist/agent-permission.d.ts.map +1 -0
  9. package/dist/approvals.d.ts +164 -0
  10. package/dist/approvals.d.ts.map +1 -0
  11. package/dist/automation.d.ts +175 -0
  12. package/dist/automation.d.ts.map +1 -0
  13. package/dist/block-keys.d.ts +82 -0
  14. package/dist/block-keys.d.ts.map +1 -0
  15. package/dist/code-scan.d.ts +64 -0
  16. package/dist/code-scan.d.ts.map +1 -0
  17. package/dist/comment-subjects.d.ts +129 -0
  18. package/dist/comment-subjects.d.ts.map +1 -0
  19. package/dist/connections.d.ts +96 -0
  20. package/dist/connections.d.ts.map +1 -0
  21. package/dist/constants.d.ts +37 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/content-publishing.d.ts +34 -0
  24. package/dist/content-publishing.d.ts.map +1 -0
  25. package/dist/contracts.d.ts +87 -0
  26. package/dist/contracts.d.ts.map +1 -0
  27. package/dist/dataset-catalog.d.ts +91 -0
  28. package/dist/dataset-catalog.d.ts.map +1 -0
  29. package/dist/deck-analysis.d.ts +63 -0
  30. package/dist/deck-analysis.d.ts.map +1 -0
  31. package/dist/env.d.ts +2 -0
  32. package/dist/env.d.ts.map +1 -0
  33. package/dist/errors.d.ts +275 -0
  34. package/dist/errors.d.ts.map +1 -0
  35. package/dist/field-types.d.ts +304 -0
  36. package/dist/field-types.d.ts.map +1 -0
  37. package/dist/index.d.ts +79 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +7785 -0
  40. package/dist/kon-api.d.ts +914 -0
  41. package/dist/kon-api.d.ts.map +1 -0
  42. package/dist/kon-entities.d.ts +204 -0
  43. package/dist/kon-entities.d.ts.map +1 -0
  44. package/dist/kon-events.d.ts +103 -0
  45. package/dist/kon-events.d.ts.map +1 -0
  46. package/dist/kon-package.d.ts +124 -0
  47. package/dist/kon-package.d.ts.map +1 -0
  48. package/dist/link-relations.d.ts +73 -0
  49. package/dist/link-relations.d.ts.map +1 -0
  50. package/dist/meta-levels.d.ts +81 -0
  51. package/dist/meta-levels.d.ts.map +1 -0
  52. package/dist/models-sql.d.ts +110 -0
  53. package/dist/models-sql.d.ts.map +1 -0
  54. package/dist/models.d.ts +354 -0
  55. package/dist/models.d.ts.map +1 -0
  56. package/dist/operations.d.ts +428 -0
  57. package/dist/operations.d.ts.map +1 -0
  58. package/dist/promotion.d.ts +244 -0
  59. package/dist/promotion.d.ts.map +1 -0
  60. package/dist/public-site.d.ts +106 -0
  61. package/dist/public-site.d.ts.map +1 -0
  62. package/dist/render-blocks.d.ts +150 -0
  63. package/dist/render-blocks.d.ts.map +1 -0
  64. package/dist/reports.d.ts +109 -0
  65. package/dist/reports.d.ts.map +1 -0
  66. package/dist/rls-builder.d.ts +136 -0
  67. package/dist/rls-builder.d.ts.map +1 -0
  68. package/dist/safe-pattern.d.ts +47 -0
  69. package/dist/safe-pattern.d.ts.map +1 -0
  70. package/dist/schemas.d.ts +977 -0
  71. package/dist/schemas.d.ts.map +1 -0
  72. package/dist/sensitivity.d.ts +37 -0
  73. package/dist/sensitivity.d.ts.map +1 -0
  74. package/dist/signer.d.ts +67 -0
  75. package/dist/signer.d.ts.map +1 -0
  76. package/dist/tier-ranges.d.ts +37 -0
  77. package/dist/tier-ranges.d.ts.map +1 -0
  78. package/dist/types.d.ts +261 -0
  79. package/dist/types.d.ts.map +1 -0
  80. package/dist/utils.d.ts +71 -0
  81. package/dist/utils.d.ts.map +1 -0
  82. package/dist/wiki-links.d.ts +56 -0
  83. package/dist/wiki-links.d.ts.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C/B,GAAG,cAAc,CAGjB;AAED,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAKvF;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMlE;AAUD,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED,yCAAyC;AACzC,wBAAgB,eAAe,CAAC,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAI/F;AAED,iDAAiD;AACjD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAc9D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC,GACtD,eAAe,CAsFjB;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAsBnE;AAsCD,+DAA+D;AAC/D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE7D"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Automation rules: conditions, templates and steps (docs/automation.md)
3
+ * ============================================================================
4
+ *
5
+ * A rule is a stored action of type `rule`:
6
+ *
7
+ * WHEN an event arrives (or a cron fires, or someone runs it by hand)
8
+ * IF its payload meets the conditions
9
+ * THEN run these steps, in order
10
+ *
11
+ * Each step names a HANDLER. The core brings a few (`core:webhook`,
12
+ * `core:send-mail`, `core:run-agent`) and a kon contributes its own with
13
+ * `defineKon({ actionHandlers })`: the CRM knows how to create an activity,
14
+ * the core does not and must not.
15
+ *
16
+ * This file is the part that is pure: evaluating a condition, filling a
17
+ * template, checking the shape of a rule. The host runs the steps.
18
+ *
19
+ * ── WHY NOT CODE ───────────────────────────────────────────────────────────
20
+ *
21
+ * A `code` action can already do anything. A rule is for the person who is
22
+ * not going to write code: it is data, so the panel can draw it, an agent can
23
+ * read it, and a dry run can say what WOULD happen without doing it.
24
+ */
25
+ import type { KonContext } from "./kon-api";
26
+ export declare const RULE_OPERATORS: readonly ["eq", "neq", "gt", "gte", "lt", "lte", "contains", "starts_with", "in", "exists"];
27
+ export type RuleOperator = (typeof RULE_OPERATORS)[number];
28
+ export interface RuleCondition {
29
+ /** Dot path into the event payload: `deal.amount`, `status`. */
30
+ field: string;
31
+ op: RuleOperator;
32
+ /** Not used by `exists`, where `false` means "must be absent". */
33
+ value?: unknown;
34
+ }
35
+ /** `all`: every condition holds (default). `any`: at least one. */
36
+ export type RuleMatch = "all" | "any";
37
+ export declare const MAX_RULE_CONDITIONS = 20;
38
+ export declare const MAX_RULE_STEPS = 20;
39
+ export declare function isRulePath(path: unknown): path is string;
40
+ /** Reads `a.b.c` from plain data. Never follows inherited properties. */
41
+ export declare function readPath(data: unknown, path: string): unknown;
42
+ export declare function evaluateCondition(condition: RuleCondition, data: unknown): boolean;
43
+ export interface ConditionOutcome {
44
+ condition: RuleCondition;
45
+ /** What the payload had at `field`. */
46
+ actual: unknown;
47
+ passed: boolean;
48
+ }
49
+ export interface ConditionsResult {
50
+ passed: boolean;
51
+ outcomes: ConditionOutcome[];
52
+ }
53
+ /** No conditions means the rule always runs. */
54
+ export declare function evaluateConditions(conditions: readonly RuleCondition[] | undefined, data: unknown, match?: RuleMatch): ConditionsResult;
55
+ /** Why a list of conditions cannot be stored, or `null`. */
56
+ export declare function conditionsProblem(conditions: unknown, match?: unknown): string | null;
57
+ /**
58
+ * Fills `{{path}}` from `scope`, through strings, lists and objects.
59
+ *
60
+ * A string that is ONLY a placeholder keeps the type of what it points to
61
+ * (`"{{event.amount}}"` becomes the number 500, not "500"): a handler that
62
+ * expects a number must not have to parse one. A placeholder that points
63
+ * nowhere becomes an empty string, or `null` when it stands alone.
64
+ */
65
+ export declare function fillTemplate<T>(value: T, scope: unknown, depth?: number): T;
66
+ export interface RuleStep {
67
+ /** `core:webhook`, `kon-crm:create-activity`. */
68
+ handler: string;
69
+ /** The handler's settings. Strings may carry `{{event.field}}` placeholders. */
70
+ config?: Record<string, unknown>;
71
+ /** Keep going with the next step when this one fails. Default: stop. */
72
+ continueOnError?: boolean;
73
+ }
74
+ /** `config` of a stored action of type `rule`. */
75
+ export interface RuleConfig {
76
+ steps: RuleStep[];
77
+ }
78
+ /** What the trigger of a rule adds to the usual trigger config. */
79
+ export interface RuleTriggerConditions {
80
+ conditions?: RuleCondition[];
81
+ match?: RuleMatch;
82
+ }
83
+ /** `<source>:<name>`: `core:webhook`, `kon-crm:create-activity`. */
84
+ export declare const RULE_HANDLER_ID: RegExp;
85
+ export interface AutomationHandlerInput {
86
+ /** The step's config, with its placeholders already filled. */
87
+ config: Record<string, unknown>;
88
+ /** The event that fired the rule; absent for cron and manual runs. */
89
+ event?: {
90
+ name: string;
91
+ data: Record<string, unknown>;
92
+ };
93
+ rule: {
94
+ id: string;
95
+ name: string;
96
+ };
97
+ /**
98
+ * The account that answers for the rule: whoever created it. `null` when
99
+ * that account no longer exists.
100
+ */
101
+ actorUserId: string | null;
102
+ }
103
+ /**
104
+ * A step a kon contributes. Declared in `defineKon({ actionHandlers })`; the
105
+ * host exposes it as `<kon id>:<id>`.
106
+ */
107
+ export interface AutomationHandlerDefinition {
108
+ /** Unique inside the kon: `create-activity`. */
109
+ id: string;
110
+ /** For the panel: "Create an activity". */
111
+ label: string;
112
+ description: string;
113
+ /** The config, field by field: documentation for whoever writes the rule. */
114
+ config?: Record<string, string>;
115
+ /** Why this config cannot be saved, or `null`. Runs when the rule is stored. */
116
+ validate?(config: Record<string, unknown>): string | null;
117
+ /**
118
+ * Does the work. Runs after the triggering request committed, outside any
119
+ * request: `ctx.db.instance` is the system connection, so the handler must
120
+ * apply `input.actorUserId` itself where ownership matters. It may run more
121
+ * than once for the same event if the rule is run again by hand: make it
122
+ * idempotent where a repeat would hurt.
123
+ */
124
+ run(input: AutomationHandlerInput, ctx: KonContext): Promise<unknown>;
125
+ /**
126
+ * What `run` WOULD do, without doing it: shown by a dry run. Without it the
127
+ * dry run shows the filled config.
128
+ */
129
+ preview?(input: AutomationHandlerInput, ctx: KonContext): Promise<unknown> | unknown;
130
+ }
131
+ /** `stage-42-enter`: unique inside the kon. */
132
+ export declare const KON_RULE_SLUG: RegExp;
133
+ /** A rule a kon creates on behalf of its own configuration (a pipeline stage's "on enter"). */
134
+ export interface KonRule {
135
+ /** Unique inside the kon; writing the same slug again replaces the rule. */
136
+ slug: string;
137
+ name: string;
138
+ description?: string;
139
+ /** The event that fires it. */
140
+ event: string;
141
+ conditions?: RuleCondition[];
142
+ match?: RuleMatch;
143
+ /** Only this kon's own handlers (`<kon id>:<id>`): a kon does not wire webhooks or agents for a person. */
144
+ steps: RuleStep[];
145
+ /** Default true. A paused rule is kept but does not run. */
146
+ enabled?: boolean;
147
+ /**
148
+ * The account that answers for the rule (who configured the stage). Handlers
149
+ * receive it as `actorUserId`.
150
+ */
151
+ ownerUserId?: string | null;
152
+ }
153
+ export interface KonRuleInfo {
154
+ id: string;
155
+ slug: string;
156
+ name: string;
157
+ event: string;
158
+ enabled: boolean;
159
+ }
160
+ /**
161
+ * `ctx.automation`. Its presence is the capability: a host that has it runs
162
+ * kon-contributed steps, so a kon may retire its own runner.
163
+ *
164
+ * `konId` is the kon's own id. A kon only sees and changes the rules it wrote.
165
+ */
166
+ export interface KonAutomation {
167
+ /** Creates the rule or replaces the one with the same slug. Idempotent. */
168
+ upsertRule(konId: string, rule: KonRule): Promise<KonRuleInfo>;
169
+ /** `true` when there was one. */
170
+ removeRule(konId: string, slug: string): Promise<boolean>;
171
+ listRules(konId: string): Promise<KonRuleInfo[]>;
172
+ }
173
+ /** Why a rule's `config` cannot be stored, or `null`. Handler existence is the host's check. */
174
+ export declare function ruleConfigProblem(config: unknown): string | null;
175
+ //# sourceMappingURL=automation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation.d.ts","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAM5C,eAAO,MAAM,cAAc,6FAWjB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,MAAM,WAAW,aAAa;IAC5B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,YAAY,CAAC;IACjB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,cAAc,KAAK,CAAC;AAQjC,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAIxD;AAED,yEAAyE;AACzE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAS7D;AAuCD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAyClF;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,CAAC;IACzB,uCAAuC;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,gBAA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IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,2EAA2E;IAC3E,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/D,iCAAiC;IACjC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CAClD;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAqBhE"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The block contract's key names, and the bridge from the 0.8 (Spanish) ones
3
+ * ============================================================================
4
+ *
5
+ * Block data (`block_contents.content`, `block_templates.content`, the `data` of every block in
6
+ * `blog_posts.blocks` and `games.blocks`) and the editorial layer kon-games keeps over a game's
7
+ * blocks (`games.blocks[].editorial`) are stored JSON that travels to the admin panel, to Inti
8
+ * (`@intijs/adapter-kitsuden`) and to the sites that render blocks. Up to 0.8 their keys were
9
+ * Spanish (`titulo`, `descripcion`, `campos`, `oculto`, `orden`…); from 0.9 they are English.
10
+ *
11
+ * The tables below are the WHOLE rename, and three places follow them:
12
+ *
13
+ * - the migrations that rewrite stored JSON (`packages/core/blocks/migrations/0010_english_block_keys.sql`,
14
+ * kon-games `0003_english_block_keys.sql`, kon-blog `0010_english_block_keys.sql`), which repeat
15
+ * these tables in SQL. `tests/unit/block-keys.test.ts` runs them against these functions;
16
+ * - the READ side (`readBlockData`, `readEditorial`): data a 0.8 writer left behind still renders.
17
+ * Remove in 0.10;
18
+ * - the WRITE side (`findSpanishBlockKeys`, `findSpanishEditorialKeys`): a write that still uses
19
+ * a 0.8 name is a 422 whose hint names the English key, never a silent save of a key nobody
20
+ * reads.
21
+ *
22
+ * The rule for one key, everywhere: if only the Spanish key is there it moves to the English one
23
+ * (with its value translated when the value is a Spanish word from a closed list); if both are
24
+ * there the English value wins and the Spanish one is dropped; anything else is left as it is.
25
+ */
26
+ /** Old (0.8) name → English name. */
27
+ export type KeyRenames = Readonly<Record<string, string>>;
28
+ /** Keys that every block type may carry at the top of its data. */
29
+ export declare const COMMON_BLOCK_KEYS: KeyRenames;
30
+ /** Top-level keys that only some block types carry. */
31
+ export declare const BLOCK_KEYS_BY_TYPE: Readonly<Record<string, KeyRenames>>;
32
+ /** Inside `fields`: which column of the dataset row is each thing. */
33
+ export declare const FIELD_KEYS: KeyRenames;
34
+ /** Each element of `facets`, `chips` and `skills.groups`. */
35
+ export declare const ITEM_KEYS: KeyRenames;
36
+ /** A linked dataset (`skills`, `trait`, `evolution`, `news` of a `dex` block). */
37
+ export declare const LINKED_DATASET_KEYS: KeyRenames;
38
+ /** `labels` of an `affinity` block: what each piece of the inheritance tree is called. */
39
+ export declare const LABEL_KEYS: KeyRenames;
40
+ /** Values that were Spanish words from a closed list, by block type and (English) key. */
41
+ export declare const BLOCK_VALUES_BY_TYPE: Readonly<Record<string, Readonly<Record<string, KeyRenames>>>>;
42
+ /** The editorial layer kon-games keeps over each game block. */
43
+ export declare const EDITORIAL_KEYS: KeyRenames;
44
+ /**
45
+ * Block data with the English keys, accepting the 0.8 (Spanish) ones.
46
+ *
47
+ * Remove in 0.10: by then every stored block has gone through the 0.9 migrations, and a writer
48
+ * that still sends Spanish keys has been getting a 422 for a whole version.
49
+ *
50
+ * Anything that is not a plain object comes back untouched, and an object that has no old key
51
+ * comes back as the SAME object.
52
+ */
53
+ export declare function readBlockData<T = unknown>(type: unknown, data: T): T;
54
+ /**
55
+ * The editorial layer of a game block with the English keys, accepting the 0.8 ones
56
+ * (`titulo`, `descripcion`, `oculto`, `orden`). Same rule as `readBlockData`.
57
+ */
58
+ export declare function readEditorial<T = unknown>(layer: T): T;
59
+ /** A 0.8 key (or value) found in a write. */
60
+ export interface SpanishKey {
61
+ /** Where: `titulo`, `fields.nombre`, `facets[0].campo`, `order` (for a value). */
62
+ path: string;
63
+ /** What to send instead. */
64
+ use: string;
65
+ }
66
+ /**
67
+ * Every 0.8 key in a block's data, nested ones included, and every Spanish value from a closed
68
+ * list (`order: "mejores"`). Empty = the data speaks the 0.9 contract.
69
+ */
70
+ export declare function findSpanishBlockKeys(type: unknown, data: unknown): SpanishKey[];
71
+ /** Every 0.8 key in an editorial layer (or a body for it). */
72
+ export declare function findSpanishEditorialKeys(layer: unknown): SpanishKey[];
73
+ /**
74
+ * The body of the 422 for a write that still uses 0.8 names: `error` says what is wrong, `hint`
75
+ * names the English key(s), `renamed` lists them for a client that wants to fix them itself.
76
+ */
77
+ export declare function spanishKeysError(found: SpanishKey[], where?: string): {
78
+ error: string;
79
+ hint: string;
80
+ renamed: SpanishKey[];
81
+ };
82
+ //# sourceMappingURL=block-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-keys.d.ts","sourceRoot":"","sources":["../src/block-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,qCAAqC;AACrC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1D,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,EAAE,UAK/B,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAkBnE,CAAC;AAEF,sEAAsE;AACtE,eAAO,MAAM,UAAU,EAAE,UAUxB,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,SAAS,EAAE,UAAuE,CAAC;AAEhG,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,EAAE,UAOjC,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,UAAU,EAAE,UAAqC,CAAC;AAE/D,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAI7F,CAAC;AAEJ,gEAAgE;AAChE,eAAO,MAAM,cAAc,EAAE,UAK5B,CAAC;AA0DF;;;;;;;;GAQG;AAEH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAgBpE;AAkBD;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEtD;AAED,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,EAAE,MAAM,CAAC;CACb;AAQD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,UAAU,EAAE,CAwC/E;AAED,8DAA8D;AAC9D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,EAAE,CAIrE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,KAAK,SAAe,GACnB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CASxD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Security scan of a draft's code — local and deterministic
3
+ * ============================================================================
4
+ *
5
+ * No network, no language models, no dependencies: a JavaScript token reader
6
+ * just good enough not to confuse comments and strings with code, and a few
7
+ * fixed rules. The same input gives the same output (the tests pin it).
8
+ *
9
+ * What it looks at:
10
+ *
11
+ * high `eval`, `Function`, `import()`, `constructor` / `__proto__`
12
+ * (the classic ways out of an interpreter), globals that are not
13
+ * part of the sandbox (`process`, `require`, `globalThis`, `Bun`…) and
14
+ * the prologue's internal functions (`__request`, `__api`…), secrets
15
+ * written in the code, and code over 64 KiB.
16
+ * medium obfuscation (`atob`, `fromCharCode`, many `\x` sequences),
17
+ * extremely long lines (minified code nobody reviews), a
18
+ * `fetch` to a host that was not declared, and `kitsuden` used in a
19
+ * way that hides which API path it calls (alias,
20
+ * `kitsuden["api"]`…): then the call stays "unclassified".
21
+ * Also: `env` used as a whole, a percent-escape in a literal API
22
+ * path, a member name built at run time, and a `/` this lexer cannot
23
+ * settle. It is a lexer, not a parser: when in doubt it reports.
24
+ * low loops with no apparent exit (the sandbox cuts them by time).
25
+ *
26
+ * `passed` = no `high` or `medium` finding.
27
+ *
28
+ * It also extracts what the rest of code promotion needs to decide: the calls to
29
+ * `kitsuden.api.*` with their method and literal path (or `null` if
30
+ * dynamic), the literal hosts of `fetch` and the `env` variables it reads.
31
+ *
32
+ * A message NEVER repeats the secret found: it gives the line and the type.
33
+ */
34
+ export type FindingSeverity = "high" | "medium" | "low";
35
+ export interface ScanFinding {
36
+ rule: string;
37
+ severity: FindingSeverity;
38
+ line: number;
39
+ message: string;
40
+ }
41
+ export interface ApiCallInfo {
42
+ method: string;
43
+ /** Literal path (`/api/...`) or `null` if computed at run time. */
44
+ path: string | null;
45
+ line: number;
46
+ }
47
+ export interface ScanReport {
48
+ version: 1;
49
+ passed: boolean;
50
+ bytes: number;
51
+ findings: ScanFinding[];
52
+ apiCalls: ApiCallInfo[];
53
+ fetchHosts: string[];
54
+ /** `true` if there is a `fetch` whose URL is not literal (the allowlist stops it at run time). */
55
+ dynamicFetch: boolean;
56
+ envVars: string[];
57
+ }
58
+ export declare const MAX_SCANNABLE_BYTES: number;
59
+ export interface ScanOptions {
60
+ /** Declared hosts (the draft's `fetchAllow`). */
61
+ fetchAllow?: readonly string[];
62
+ }
63
+ export declare function scanCode(code: string, options?: ScanOptions): ScanReport;
64
+ //# sourceMappingURL=code-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-scan.d.ts","sourceRoot":"","sources":["../src/code-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,CAAC,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,kGAAkG;IAClG,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,eAAO,MAAM,mBAAmB,QAAY,CAAC;AA2a7C,MAAM,WAAW,WAAW;IAC1B,iDAAiD;IACjD,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAmDD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,UAAU,CAoY5E"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * What can be commented on, declared in ONE place
3
+ * ============================================================================
4
+ *
5
+ * ── THE PROBLEM THIS SOLVES ────────────────────────────────────────────────
6
+ *
7
+ * `kon-comments` is polymorphic: a comment hangs off `(subjectType,
8
+ * subjectId)` with no foreign key, and that is why the same engine serves
9
+ * articles, wiki pages and catalog entries without repeating threads, votes and
10
+ * moderation five times. It is the right decision.
11
+ *
12
+ * But `subjectType` was only validated by SHAPE:
13
+ *
14
+ * subjectType: z.string().min(1).max(60).regex(/^[a-z0-9_]+$/)
15
+ *
16
+ * So `post`, `blog_post` and `blogpost` are all accepted and create THREE
17
+ * different threads on the same article. Whoever writes the page picks one
18
+ * string, whoever writes the sidebar widget picks another, and the comments
19
+ * simply do not show up where expected. No error, no log, and nothing to
20
+ * search for: both sides "work".
21
+ *
22
+ * ── WHY A VOCABULARY DOES NOT KILL POLYMORPHISM ────────────────────────────
23
+ *
24
+ * It might seem that closing the list contradicts the design. It does not: what
25
+ * is closed is WRITING, and adding a type costs one line here. What used to be
26
+ * a silent typo becomes a deliberate act. Reading still accepts any string,
27
+ * because asking for a thread that does not exist returns an empty list and
28
+ * breaks nothing.
29
+ *
30
+ * ── AND, WHILE AT IT, VISIBILITY ───────────────────────────────────────────
31
+ *
32
+ * Each entry says which table the subject is in and which of its states are
33
+ * public. With that, `kon-comments` can check that the subject EXISTS and is
34
+ * visible without importing a single kon: the table comes from this literal,
35
+ * never from the request.
36
+ *
37
+ * Without that check, comments can be attached to the id of a draft, and
38
+ * since reading threads is public, the thread of an unpublished article
39
+ * would be readable from outside. It is the same family of leak that already
40
+ * appeared in blog, games and esports.
41
+ */
42
+ /** Something commentable: where it lives and when it is public. */
43
+ export interface CommentableSubject {
44
+ /** For error messages and for the panel. */
45
+ label: string;
46
+ /** Who owns the subject. Documentary: nothing is imported here. */
47
+ kon: string;
48
+ /**
49
+ * Table where it lives. It comes from this literal and NEVER from the request:
50
+ * that is what allows interpolating it into a query without opening an injection.
51
+ */
52
+ table: string;
53
+ /** Status column, if it has one. `null` = everything that exists is public. */
54
+ statusColumn: string | null;
55
+ /** States that a visitor without permissions can see. */
56
+ publicStatuses: string[];
57
+ /**
58
+ * Column with the subject's human-readable name.
59
+ *
60
+ * ── WHY IT IS HERE ───────────────────────────────────────────────────────
61
+ *
62
+ * Without this, the moderation queue shows a comment body next to a
63
+ * uuid. Whoever moderates needs to know WHICH article it comes from to decide:
64
+ * the same text can be a legitimate reply in one thread and spam in another. It
65
+ * is WordPress's "In response to" column, and without it moderating is guessing.
66
+ */
67
+ titleColumn: string;
68
+ /** Slug column, so it can link to the public site. */
69
+ slugColumn: string;
70
+ }
71
+ /**
72
+ * The vocabulary.
73
+ *
74
+ * Only what really exists and is wired up. Declaring `game` or
75
+ * `build` here before anything uses them would be inventing: an unused entry
76
+ * is not reviewed, and the day someone uses it, it may point to a table that
77
+ * was renamed.
78
+ */
79
+ export declare const COMMENTABLE_SUBJECTS: {
80
+ readonly blog_post: {
81
+ readonly label: "Blog article";
82
+ readonly kon: "kon-blog";
83
+ readonly table: "blog_posts";
84
+ readonly statusColumn: "status";
85
+ readonly publicStatuses: ["published"];
86
+ readonly titleColumn: "title";
87
+ readonly slugColumn: "slug";
88
+ };
89
+ /**
90
+ * A page of the block builder.
91
+ *
92
+ * It is here because the comments block says "empty = this page's subject",
93
+ * and without this entry that sentence had nothing to refer to on a block
94
+ * page: the vocabulary only knew articles. Promising a behavior that does
95
+ * not exist sends people looking for a bug where there is none.
96
+ */
97
+ readonly block_page: {
98
+ readonly label: "Builder page";
99
+ readonly kon: "kon-blocks";
100
+ readonly table: "block_pages";
101
+ readonly statusColumn: "status";
102
+ readonly publicStatuses: ["published"];
103
+ readonly titleColumn: "title";
104
+ readonly slugColumn: "slug";
105
+ };
106
+ /**
107
+ * A page of a wiki (kon-wiki). Stateless: every page that exists is
108
+ * public, and its content can be edited by any session.
109
+ *
110
+ * Used by the wiki entry page (`<wiki>.<domain>/<page>`), "Comments"
111
+ * tab. The id is that of `wiki_pages`, not the slug: the slug is only
112
+ * unique within its wiki.
113
+ */
114
+ readonly wiki_page: {
115
+ readonly label: "Wiki page";
116
+ readonly kon: "kon-wiki";
117
+ readonly table: "wiki_pages";
118
+ readonly statusColumn: null;
119
+ readonly publicStatuses: [];
120
+ readonly titleColumn: "title";
121
+ readonly slugColumn: "slug";
122
+ };
123
+ };
124
+ export type SubjectType = keyof typeof COMMENTABLE_SUBJECTS;
125
+ /** The valid types, for error messages that say which ones they are. */
126
+ export declare const SUBJECT_TYPES: SubjectType[];
127
+ export declare function isSubjectType(type: string): type is SubjectType;
128
+ export declare function commentableSubject(type: string): CommentableSubject | null;
129
+ //# sourceMappingURL=comment-subjects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-subjects.d.ts","sourceRoot":"","sources":["../src/comment-subjects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,yDAAyD;IACzD,cAAc,EAAE,MAAM,EAAE,CAAC;IAEzB;;;;;;;;;OASG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;IAU/B;;;;;;;OAOG;;;;;;;;;;IAUH;;;;;;;OAOG;;;;;;;;;;CAUkD,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,oBAAoB,CAAC;AAE5D,wEAAwE;AACxE,eAAO,MAAM,aAAa,EAAwC,WAAW,EAAE,CAAC;AAEhF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,WAAW,CAE/D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAE1E"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Connections: the contract (docs/connections.md)
3
+ * ============================================================================
4
+ *
5
+ * Accounts at other services (a person's Google or Microsoft 365 mailbox, the organization's Stripe or
6
+ * Resend key), connected once in the core and used by every kon that needs one. A kon never sees a
7
+ * token or a key: it asks `ctx.connections.client(...)` for a `fetch` that adds the credential itself and
8
+ * only sends it, over https, to the provider's own hosts.
9
+ *
10
+ * const google = await ctx.connections.client("kon-inbox", {
11
+ * provider: "google",
12
+ * ownerId: userId, // that person's own connection; omit for the organization's
13
+ * scopeSets: ["mail.read"],
14
+ * purpose: "sync mail", // recorded, with the kon's id, every time the credential opens
15
+ * });
16
+ * const res = await google.fetch("https://gmail.googleapis.com/gmail/v1/users/me/messages");
17
+ *
18
+ * Like `ctx.secrets`, every method takes the calling kon's id first; the host binds it, and a kon that
19
+ * passes another id is refused.
20
+ */
21
+ /** A connection as every route and every kon sees it: never a credential. */
22
+ export interface PublicConnection {
23
+ id: string;
24
+ provider: string;
25
+ scope: "user" | "organization";
26
+ ownerId: string | null;
27
+ authType: "oauth" | "api_key";
28
+ label: string;
29
+ accountId: string | null;
30
+ accountEmail: string | null;
31
+ grantedScopes: string[];
32
+ status: "active" | "expired" | "revoked" | "error";
33
+ expiresAt: string | null;
34
+ lastRefreshedAt: string | null;
35
+ lastUsedAt: string | null;
36
+ lastError: string | null;
37
+ createdAt: string;
38
+ }
39
+ /** What a kon asks for. */
40
+ export interface ConnectionRequest {
41
+ provider: string;
42
+ /** A person's own connection; without it, the organization's. */
43
+ ownerId?: string | null;
44
+ /** One connection in particular (it must still match `provider` and the owner). */
45
+ connectionId?: string;
46
+ /** Named scope sets the connection must cover (`mail.read`). */
47
+ scopeSets?: string[];
48
+ /** Why the credential is opened, for the access log. Never a token. */
49
+ purpose: string;
50
+ /** The person the work is done for, if any. */
51
+ actorUserId?: string | null;
52
+ }
53
+ export interface ConnectedClient {
54
+ connection: PublicConnection;
55
+ fetch(url: string, init?: RequestInit): Promise<Response>;
56
+ }
57
+ /** A provider a kon adds to the catalog (an API key service, typically). */
58
+ export interface ConnectionProviderDefinition {
59
+ /** `stripe`, `resend`: lower case, the id stored on each connection. */
60
+ id: string;
61
+ name: string;
62
+ authTypes: Array<"oauth" | "api_key">;
63
+ /** Named scope sets a kon or a person may ask for. */
64
+ scopeSets: Record<string, {
65
+ description: string;
66
+ scopes: string[];
67
+ }>;
68
+ /** Hosts the credential may be sent to (https only). */
69
+ apiHosts: string[];
70
+ /** How an API key goes on a request. Default `Authorization: Bearer <key>`; `encode` for anything else. */
71
+ apiKeyHeader?: {
72
+ name: string;
73
+ prefix?: string;
74
+ encode?: (key: string) => string;
75
+ };
76
+ }
77
+ export interface KonConnections {
78
+ /** A client for the best active connection that matches; throws when none does. */
79
+ client(konId: string, request: ConnectionRequest): Promise<ConnectedClient>;
80
+ /**
81
+ * Adds a provider to the catalog, owned by this kon. Google and Microsoft, and a provider another kon
82
+ * registered, cannot be replaced.
83
+ */
84
+ registerProvider(konId: string, provider: ConnectionProviderDefinition): void;
85
+ /** A connection as the CALLER of the current request may see it (row security), or `null`. */
86
+ visible(konId: string, connectionId: string): Promise<PublicConnection | null>;
87
+ /** Whether granted scopes cover the named sets of a provider. */
88
+ covers(provider: string, grantedScopes: string[], scopeSets: string[]): boolean;
89
+ }
90
+ /** The events the core emits about connections. */
91
+ export declare const CONNECTION_EVENTS: {
92
+ readonly created: "connections:connection.created";
93
+ readonly expired: "connections:connection.expired";
94
+ readonly revoked: "connections:connection.revoked";
95
+ };
96
+ //# sourceMappingURL=connections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,EA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AE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;IACtC,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACrE,wDAAwD;IACxD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,2GAA2G;IAC3G,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;CACpF;AAED,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC5E;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC9E,8FAA8F;IAC9F,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC/E,iEAAiE;IACjE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;CACjF;AAED,mDAAmD;AACnD,eAAO,MAAM,iBAAiB;;;;CAIpB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Kitsuden Shared Constants
3
+ */
4
+ export declare const SITE_CONFIG: {
5
+ readonly name: "Kitsuden";
6
+ readonly description: "High-Performance Gaming CMS";
7
+ readonly defaultLocale: "en";
8
+ readonly postsPerPage: 12;
9
+ readonly gamesPerPage: 24;
10
+ };
11
+ export declare const BREAKPOINTS: {
12
+ readonly sm: 640;
13
+ readonly md: 768;
14
+ readonly lg: 1024;
15
+ readonly xl: 1280;
16
+ readonly "2xl": 1536;
17
+ };
18
+ export declare const NEON_COLORS: {
19
+ readonly cyan: "#00E5FF";
20
+ readonly pink: "#FF2A6D";
21
+ readonly green: "#76FF03";
22
+ readonly yellow: "#FFD600";
23
+ readonly purple: "#E040FB";
24
+ readonly orange: "#FF6D00";
25
+ };
26
+ export declare const COLLECTION_SLUGS: {
27
+ readonly users: "users";
28
+ readonly games: "games";
29
+ readonly platforms: "platforms";
30
+ readonly blogPosts: "blog-posts";
31
+ readonly media: "media";
32
+ readonly tags: "tags";
33
+ readonly dataSets: "data-sets";
34
+ readonly dataEntries: "data-entries";
35
+ readonly streamers: "streamers";
36
+ };
37
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;;CAOd,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;CAUnB,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Content Publishing Registry
3
+ *
4
+ * Manages content targets for promoting data to different outputs
5
+ * (Blog, CMS, Email, etc.)
6
+ */
7
+ import type { KonContext, ContentTarget } from "./kon-api";
8
+ export declare class ContentPublishingRegistry {
9
+ private targets;
10
+ private ctx;
11
+ constructor(ctx: KonContext);
12
+ /**
13
+ * Register a content target
14
+ */
15
+ register(target: ContentTarget): void;
16
+ /**
17
+ * Unregister a content target
18
+ */
19
+ unregister(targetId: string): void;
20
+ /**
21
+ * Get a content target by ID
22
+ */
23
+ get(targetId: string): ContentTarget | undefined;
24
+ /**
25
+ * Get all registered content targets
26
+ */
27
+ getAll(): ContentTarget[];
28
+ /**
29
+ * Check if a target is registered
30
+ */
31
+ has(targetId: string): boolean;
32
+ }
33
+ export type { ContentTarget } from "./kon-api";
34
+ //# sourceMappingURL=content-publishing.d.ts.map