@sanoma-ai/workflows 0.1.0 → 0.2.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 (99) hide show
  1. package/README.md +72 -21
  2. package/dist/apply-steps.d.ts +6 -0
  3. package/dist/apply-steps.js +93 -0
  4. package/dist/apply-steps.js.map +1 -0
  5. package/dist/apply.d.ts +197 -0
  6. package/dist/apply.js +470 -0
  7. package/dist/apply.js.map +1 -0
  8. package/dist/call.d.ts +4 -0
  9. package/dist/call.js +19 -4
  10. package/dist/call.js.map +1 -1
  11. package/dist/client.d.ts +38 -2
  12. package/dist/client.js +67 -10
  13. package/dist/client.js.map +1 -1
  14. package/dist/config.d.ts +3 -3
  15. package/dist/config.js +33 -16
  16. package/dist/config.js.map +1 -1
  17. package/dist/credentials.d.ts +25 -0
  18. package/dist/credentials.js +73 -5
  19. package/dist/credentials.js.map +1 -1
  20. package/dist/datafile.d.ts +11 -2
  21. package/dist/datafile.js +56 -2
  22. package/dist/datafile.js.map +1 -1
  23. package/dist/describe.d.ts +11 -5
  24. package/dist/describe.js +13 -5
  25. package/dist/describe.js.map +1 -1
  26. package/dist/drift.d.ts +64 -12
  27. package/dist/drift.js +118 -41
  28. package/dist/drift.js.map +1 -1
  29. package/dist/expectations.d.ts +2 -2
  30. package/dist/expectations.js +28 -3
  31. package/dist/expectations.js.map +1 -1
  32. package/dist/host.d.ts +56 -0
  33. package/dist/host.js +45 -0
  34. package/dist/host.js.map +1 -0
  35. package/dist/index.d.ts +6 -2
  36. package/dist/index.js +5 -1
  37. package/dist/index.js.map +1 -1
  38. package/dist/lockfile.d.ts +36 -0
  39. package/dist/lockfile.js +69 -0
  40. package/dist/lockfile.js.map +1 -0
  41. package/dist/op.d.ts +3 -0
  42. package/dist/op.js.map +1 -1
  43. package/dist/resource.d.ts +188 -22
  44. package/dist/resource.js +173 -28
  45. package/dist/resource.js.map +1 -1
  46. package/dist/resources.d.ts +18 -3
  47. package/dist/resources.js +53 -6
  48. package/dist/resources.js.map +1 -1
  49. package/dist/run.d.ts +14 -0
  50. package/dist/run.js +6 -1
  51. package/dist/run.js.map +1 -1
  52. package/dist/sandbox.js +5 -1
  53. package/dist/sandbox.js.map +1 -1
  54. package/dist/scenario.d.ts +12 -3
  55. package/dist/scenario.js +33 -8
  56. package/dist/scenario.js.map +1 -1
  57. package/dist/secret.d.ts +42 -0
  58. package/dist/secret.js +58 -0
  59. package/dist/secret.js.map +1 -0
  60. package/dist/shared.d.ts +8 -0
  61. package/dist/shared.js +7 -0
  62. package/dist/shared.js.map +1 -1
  63. package/dist/source.d.ts +58 -0
  64. package/dist/source.js +54 -0
  65. package/dist/source.js.map +1 -0
  66. package/dist/version.d.ts +1 -1
  67. package/dist/version.js +1 -1
  68. package/dist/worker.d.ts +3 -0
  69. package/dist/worker.js +13 -4
  70. package/dist/worker.js.map +1 -1
  71. package/dist/writer.d.ts +35 -0
  72. package/dist/writer.js +201 -0
  73. package/dist/writer.js.map +1 -0
  74. package/package.json +6 -1
  75. package/src/apply-steps.ts +110 -0
  76. package/src/apply.ts +626 -0
  77. package/src/call.ts +19 -4
  78. package/src/client.ts +83 -13
  79. package/src/config.ts +48 -25
  80. package/src/credentials.ts +90 -5
  81. package/src/datafile.ts +76 -4
  82. package/src/describe.ts +36 -16
  83. package/src/drift.ts +155 -45
  84. package/src/expectations.ts +30 -4
  85. package/src/host.ts +96 -0
  86. package/src/index.ts +24 -1
  87. package/src/lockfile.ts +95 -0
  88. package/src/op.ts +3 -0
  89. package/src/resource.ts +270 -47
  90. package/src/resources.ts +63 -8
  91. package/src/run.ts +15 -0
  92. package/src/sandbox.ts +5 -1
  93. package/src/scenario.ts +50 -13
  94. package/src/secret.ts +92 -0
  95. package/src/shared.ts +10 -0
  96. package/src/source.ts +82 -0
  97. package/src/version.ts +1 -1
  98. package/src/worker.ts +16 -5
  99. package/src/writer.ts +225 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lockfile.js","sourceR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GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI;YAAE,OAAO,EAAE,CAAC;QAC1D,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/op.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { z } from "zod";
2
2
  import type { Fake } from "./fake.ts";
3
+ import type { Secrets } from "./secret.ts";
3
4
  import type { Steps } from "./steps.ts";
4
5
  /**
5
6
  * What an operation does to the outside world. It sets the badge a reviewer
@@ -152,6 +153,8 @@ export interface CallContext {
152
153
  opId: string;
153
154
  /** 1 on the first try; retries count up (idempotent operations only). */
154
155
  attempt: number;
156
+ /** The secrets store, for the values `secret()` markers name: `resolveSecrets(input, call.secrets)`. In memory for a fake. */
157
+ secrets: Secrets;
155
158
  }
156
159
  export type DriverFn<I = any, O = unknown> = (input: I, call: CallContext) => Promise<O>;
157
160
  /**
package/dist/op.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"op.js","sourceRoot":"","sources":["../src/op.ts"],"names":[],"mappings":"AA2DA;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAkBrE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAcjE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAiClC,kEAAkE;AAClE,MAAM,WAAW,GAAG,iCAAiC,CAAC;AAEtD,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE,CACjE,CAAC,OAAO,KAAK,KAAK,UAAU,IAAI,OAAO,KAAK,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EAAE,CAAC,CAAC;AACtG,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import { z } from "zod";
2
+ import { type HostSpec } from "./host.ts";
2
3
  import { type Connector, type OpSpec, RESOURCE } from "./op.ts";
4
+ import { type Secret } from "./secret.ts";
3
5
  /** Which fields of a resource are flagged, by dotted path (`pages.html_url`; a list's items have no index). */
4
6
  export interface ResourceFields {
5
7
  /** Changing it replaces the object. */
@@ -44,20 +46,62 @@ export interface ResourceSpec<S extends z.ZodObject = z.ZodObject> {
44
46
  title: string;
45
47
  /**
46
48
  * How `find` makes the import id, for people: `name`, `repository_id:pattern`. The fields it
47
- * names stay declarable even when the vendor sets them (Stripe's `id`).
49
+ * names stay declarable even when the vendor sets them. Absent with `find`: a type the vendor
50
+ * names alone (Stripe's) is found only by its binding.
48
51
  */
49
- identity: string;
52
+ identity?: string;
50
53
  /** The resource's fields as a read returns them; a data file declares them, less the vendor-owned ones. */
51
54
  schema: S;
52
55
  fields: ResourceFields;
53
- /** The vendor's id for a declared resource (the import id), from its declared fields. */
54
- find: (desired: z.input<S>) => string;
56
+ /**
57
+ * The import id that finds a declared resource before it is bound, from its declared fields:
58
+ * its identity. Absent when its fields cannot name it.
59
+ */
60
+ find?: (desired: z.input<S>) => string;
61
+ /**
62
+ * The id a binding keeps for an object, from its state: stable for the object's life (GitHub's
63
+ * `node_id`, not its name), and one `import` accepts. Default: `String(state.id)`.
64
+ */
65
+ bindingId?: (state: State) => string;
55
66
  /**
56
67
  * The part of a state that a drift check compares, given what was declared. The check
57
68
  * compares `normalize(actual, desired)` with `normalize(desired, desired)`. Default:
58
69
  * `compareDeclared`, which keeps the declared fields only.
59
70
  */
60
71
  normalize?: (state: State, desired: z.input<S>) => State;
72
+ /**
73
+ * True when apply may change its objects: the type then has the change operations `plan`,
74
+ * `create`, `update` and `delete` besides `read` and `import`. Default false.
75
+ */
76
+ writable?: boolean;
77
+ /** Set when the type meets the `Host` contract: it runs the company. Such a type is `writable` and `stateless`. */
78
+ host?: HostSpec;
79
+ /**
80
+ * True when its objects hold no data, so one gone at the vendor is created again by apply
81
+ * without asking (a host running the company's code); otherwise apply asks first, as a
82
+ * recreated database looks fine and has lost its data. Default: true for a host, else false.
83
+ */
84
+ stateless?: boolean;
85
+ /**
86
+ * Operations apply calls, in order, right after it creates one of its objects and binds it: a
87
+ * Supabase project's health, until it is healthy, then its database URL stored.
88
+ */
89
+ afterCreate?: readonly AfterCreate[];
90
+ }
91
+ /** One operation apply calls after a create (`ResourceSpec.afterCreate`). */
92
+ export interface AfterCreate {
93
+ /** The operation's id, among the config's: `supabase.database.storeUrl`. */
94
+ op: string;
95
+ /** Its input, from the new object's binding id and the data file's export that declares it. */
96
+ input: (made: {
97
+ id: string;
98
+ export: string;
99
+ }) => unknown;
100
+ /**
101
+ * Called again, every few seconds, until its output passes this, for up to 10 minutes; a call
102
+ * that fails meanwhile is one that did not pass, its output `undefined`.
103
+ */
104
+ until?: (output: any) => boolean;
61
105
  }
62
106
  /**
63
107
  * Where a declared resource keeps its brand, its type's `<vendor>.<type>`: a symbol, so a field
@@ -70,8 +114,8 @@ export interface Declared<Id extends string = string, T = State> {
70
114
  readonly [DECLARED]: Id;
71
115
  readonly vendor: string;
72
116
  readonly type: string;
73
- /** The vendor's id for it: what `find` made of `desired`. */
74
- readonly name: string;
117
+ /** Its identity, the import id that finds it unbound: what `find` made of `desired`; absent without `find`. */
118
+ readonly name?: string;
75
119
  /**
76
120
  * Its fields, each resource it names replaced by that resource's `name`: what its type
77
121
  * checked, and what a drift check compares.
@@ -85,14 +129,24 @@ export interface Declared<Id extends string = string, T = State> {
85
129
  }
86
130
  /**
87
131
  * What a resource type's constructor takes: its fields, where `R` (its `fields.references`)
88
- * names a path, a declared resource of that type instead of a value (`repository_id: site`).
132
+ * names a path, a declared resource of that type instead of a value (`repository_id: site`), and
133
+ * where a string goes, a secret (`secret("NAME")`), which the constructor allows at a write-only
134
+ * field only.
89
135
  */
90
- export type Declaring<T, R extends References = {}> = [keyof R] extends [never] ? T : DeclaringAt<T, R, "">;
136
+ export type Declaring<T, R extends References = {}> = [keyof R] extends [never] ? WithSecrets<T> : DeclaringAt<T, R, "">;
137
+ type WithSecrets<V> = V extends string ? V | Secret : V extends readonly (infer I)[] ? WithSecrets<I>[] : V extends object ? {
138
+ [K in keyof V]: WithSecrets<V[K]>;
139
+ } : V;
91
140
  type DeclaringAt<T, R extends References, P extends string> = T extends readonly (infer I)[] ? DeclaringAt<I, R, P>[] : T extends object ? {
92
141
  [K in keyof T]: K extends string ? DeclaringField<T[K], R, P extends "" ? K : `${P}.${K}`> : T[K];
93
- } : T;
94
- type DeclaringField<V, R extends References, P extends string> = P extends keyof R ? V | DeclaredOf<R[P]["type"]> : [Extract<keyof R, `${P}.${string}`>] extends [never] ? V : DeclaringAt<V, R, P>;
142
+ } : WithSecrets<T>;
143
+ type DeclaringField<V, R extends References, P extends string> = P extends keyof R ? WithSecrets<V> | DeclaredOf<R[P]["type"]> : [Extract<keyof R, `${P}.${string}`>] extends [never] ? WithSecrets<V> : DeclaringAt<V, R, P>;
95
144
  type DeclaredOf<Id> = Id extends string ? Declared<Id> : never;
145
+ /** What a plan of a change says will happen, as `PlanResponse.Action` names it. */
146
+ export declare const PLAN_ACTIONS: readonly ["none", "create", "update", "replace", "delete"];
147
+ export type PlanAction = (typeof PLAN_ACTIONS)[number];
148
+ /** The operations of a writable type that change its objects: only the apply workflow calls them (`isChangeOp`). */
149
+ export declare const CHANGE_OPS: readonly ["create", "update", "delete"];
96
150
  declare const opsOf: <S extends z.ZodObject>(schema: S) => {
97
151
  import: {
98
152
  input: z.ZodObject<{
@@ -118,20 +172,101 @@ declare const opsOf: <S extends z.ZodObject>(schema: S) => {
118
172
  handle: z.ZodOptional<z.ZodString>;
119
173
  }, z.core.$strip>;
120
174
  };
175
+ plan: {
176
+ input: z.ZodObject<{
177
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
178
+ handle: z.ZodOptional<z.ZodString>;
179
+ id: z.ZodOptional<z.ZodString>;
180
+ desired: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
181
+ }, z.core.$strip>;
182
+ output: z.ZodObject<{
183
+ action: z.ZodEnum<{
184
+ create: "create";
185
+ delete: "delete";
186
+ none: "none";
187
+ replace: "replace";
188
+ update: "update";
189
+ }>;
190
+ planned: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
191
+ unknown: z.ZodArray<z.ZodString>;
192
+ replace: z.ZodArray<z.ZodString>;
193
+ }, z.core.$strip>;
194
+ };
195
+ create: {
196
+ input: z.ZodObject<{
197
+ desired: z.ZodRecord<z.ZodString, z.ZodUnknown>;
198
+ }, z.core.$strip>;
199
+ output: z.ZodObject<{
200
+ id: z.ZodString;
201
+ state: S;
202
+ handle: z.ZodOptional<z.ZodString>;
203
+ }, z.core.$strip>;
204
+ };
205
+ update: {
206
+ input: z.ZodObject<{
207
+ id: z.ZodString;
208
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
209
+ handle: z.ZodOptional<z.ZodString>;
210
+ desired: z.ZodRecord<z.ZodString, z.ZodUnknown>;
211
+ expect: z.ZodOptional<z.ZodObject<{
212
+ action: z.ZodEnum<{
213
+ create: "create";
214
+ delete: "delete";
215
+ none: "none";
216
+ replace: "replace";
217
+ update: "update";
218
+ }>;
219
+ replace: z.ZodArray<z.ZodString>;
220
+ }, z.core.$strip>>;
221
+ }, z.core.$strip>;
222
+ output: z.ZodObject<{
223
+ id: z.ZodString;
224
+ state: S;
225
+ handle: z.ZodOptional<z.ZodString>;
226
+ }, z.core.$strip>;
227
+ };
228
+ delete: {
229
+ input: z.ZodObject<{
230
+ id: z.ZodString;
231
+ state: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
232
+ handle: z.ZodOptional<z.ZodString>;
233
+ }, z.core.$strip>;
234
+ output: z.ZodObject<{
235
+ id: z.ZodString;
236
+ gone: z.ZodLiteral<true>;
237
+ }, z.core.$strip>;
238
+ };
121
239
  };
122
240
  type OpsOf<S extends z.ZodObject> = ReturnType<typeof opsOf<S>>;
123
- /** A resource type's operation specs: `read` and `import`. */
124
- export type ResourceOps<S extends z.ZodObject> = {
125
- [N in keyof OpsOf<S>]: OpSpec<OpsOf<S>[N]["input"], OpsOf<S>[N]["output"]>;
241
+ type Specs<S extends z.ZodObject, N extends keyof OpsOf<S>> = {
242
+ [K in N]: OpSpec<OpsOf<S>[K]["input"], OpsOf<S>[K]["output"]>;
126
243
  };
244
+ /**
245
+ * A resource type's operation specs: `read` and `import`, and for a writable type (`W`) the
246
+ * change operations `plan`, `create`, `update` and `delete`.
247
+ */
248
+ export type ResourceOps<S extends z.ZodObject, W extends boolean = false> = Specs<S, "read" | "import"> & ([W] extends [true] ? Specs<S, "plan" | (typeof CHANGE_OPS)[number]> : {});
249
+ /**
250
+ * True for an operation that changes a writable type's objects (`CHANGE_OPS`), which only the
251
+ * apply workflow may call: by its vendor, resource and name, so a copy of a connector is told too.
252
+ */
253
+ export declare function isChangeOp(op: {
254
+ readonly vendor: string;
255
+ readonly resource: string;
256
+ readonly name: string;
257
+ }, types: ReadonlyMap<string, Pick<Resource, "writable">>): boolean;
127
258
  /**
128
259
  * A resource type: call it to declare a resource in a data file, and give it to
129
260
  * `defineConnector` as a group, under its `type`: `defineConnector("github", { repository })`.
130
261
  */
131
- export interface Resource<S extends z.ZodObject = z.ZodObject, Id extends string = string, R extends References = {}> extends Readonly<Required<ResourceSpec<S>>> {
262
+ export interface Resource<S extends z.ZodObject = z.ZodObject, Id extends string = string, R extends References = {}, W extends boolean = boolean> extends Readonly<Required<Omit<ResourceSpec<S>, "identity" | "find" | "writable" | "host" | "stateless" | "afterCreate">>>, Readonly<Pick<ResourceSpec<S>, "identity" | "find" | "host" | "afterCreate">> {
132
263
  (desired: Declaring<z.input<S>, R>): Declared<Id, z.input<S>>;
133
- /** `read` and `import`, each effect `read`, idempotent, with the import id as `target`. */
134
- readonly ops: ResourceOps<S>;
264
+ /** `read` and `import`, each effect `read`, idempotent, with the id as `target`; for a writable type, the change operations too. */
265
+ readonly ops: ResourceOps<S, W>;
266
+ /** True when apply may change its objects: it has the change operations. */
267
+ readonly writable: W;
268
+ /** True when apply may recreate or replace its objects as routine: they keep no data. */
269
+ readonly stateless: boolean;
135
270
  readonly [RESOURCE]: true;
136
271
  }
137
272
  /** True for a plain object: not null, not a list. */
@@ -174,9 +309,20 @@ export declare function diffDeclared(resource: {
174
309
  readonly fields: ResourceFields;
175
310
  readonly normalize: (state: State, desired: any) => State;
176
311
  }, state: State, desired: State, accept?: Readonly<Record<string, readonly unknown[]>>): DriftField[];
312
+ /** The object or list holding the value at a dotted path (a list item's by its index), and its key there. */
313
+ export declare function holderOf(value: unknown, path: string): {
314
+ holder: State;
315
+ key: string;
316
+ } | undefined;
317
+ /** A field's dotted path as `fields` names it, without a list item's index: `teams.0` is `teams`. */
318
+ export declare const fieldPathOf: (at: string) => string;
319
+ /** The value at a dotted path, a list item's by its index. */
320
+ export declare const valueAt: (value: unknown, path: string) => unknown;
177
321
  /**
178
- * `desired` without the fields the type marks write-only (a webhook's `secret`): what a run may
179
- * record of a declaration. A list's items lose them too.
322
+ * `desired` without the values at the fields the type marks write-only (a webhook's `secret`):
323
+ * what a run may record of a declaration. A list's items lose them too. A secret marker
324
+ * (`secret("NAME")`) stays, there or inside a write-only map (a host's `secrets`): it names a
325
+ * stored secret and holds none, and the driver resolves it.
180
326
  */
181
327
  export declare function withoutWriteOnly(fields: ResourceFields, desired: State): State;
182
328
  /**
@@ -184,13 +330,31 @@ export declare function withoutWriteOnly(fields: ResourceFields, desired: State)
184
330
  * derives its operations, `<vendor>.<type>.read` and `<vendor>.<type>.import`, both effect
185
331
  * `read` and idempotent, with the import id as the policy's `target`:
186
332
  *
187
- * - `import` takes `{ id }`, the import id, and returns `{ gone: false, state }`, the object's
333
+ * - `import` takes `{ id }`, an identity (what `find` makes) or a binding id (what `bindingId`
334
+ * makes), and returns `{ gone: false, state }`, the object's
188
335
  * state (with the driver's opaque `handle` when it keeps one), or `{ gone: true }` when the
189
336
  * vendor has no such object.
190
337
  * - `read` takes `{ id, state?, handle? }`, a state from an earlier `import` or `read`, and
191
338
  * returns the same: `{ gone: true }` when the object no longer exists, else its fresh
192
339
  * `state`. A driver may import first when it is given no state.
193
340
  *
341
+ * A `writable` type has the change operations too, which only the apply workflow may call
342
+ * (`isChangeOp`): `create`, `update` and `delete` effect `write` (`delete` idempotent), and `plan`:
343
+ *
344
+ * - `plan` (`read`, idempotent) takes `{ id?, state?, handle?, desired? }`, no `desired` for a
345
+ * delete and no `id` for a create, and returns `{ action, planned?, unknown, replace }`:
346
+ * what apply would do, the new state without write-only fields, the paths known only after
347
+ * apply, and those whose change replaces the object.
348
+ * - `create` (`target` `new:<vendor>.<type>`) takes `{ desired }` and returns `{ id, state,
349
+ * handle? }`, `id` its binding id.
350
+ * - `update` takes `{ id, state?, handle?, desired, expect? }` and returns the same; given
351
+ * `expect` (a plan's `action` and `replace`), it refuses a fresh plan that differs
352
+ * (`DriverError`, `vendorCode` `plan_changed`).
353
+ * - `delete` takes `{ id, state?, handle? }` and returns `{ id, gone: true }`.
354
+ *
355
+ * `desired` may hold secret markers at write-only fields, which the driver resolves; no output
356
+ * holds a write-only value.
357
+ *
194
358
  * The ledger records a `handle` as `"<handle>"`, never its bytes (the operations' `opaque`).
195
359
  *
196
360
  * Calling the result declares one resource, for a data file: `repository({ name: "sanoma" })`
@@ -198,15 +362,17 @@ export declare function withoutWriteOnly(fields: ResourceFields, desired: State)
198
362
  * schema does not have, fields the vendor owns (unless the identity names them), values the
199
363
  * schema rejects, and an empty identity. Where `fields.references` allows it, a field may name
200
364
  * another declared resource of that type (`repository_id: site`): `desired` holds, and the
201
- * schema and `find` read, that resource's `name`, and `refs` says where it was named.
365
+ * schema and `find` read, that resource's `name`, and `refs` says where it was named. A type
366
+ * without `find` declares resources without a `name`, found only by their bindings.
202
367
  */
203
- export declare function defineResource<S extends z.ZodObject, const V extends string, const T extends string, const R extends References = {}>(spec: ResourceSpec<S> & {
368
+ export declare function defineResource<S extends z.ZodObject, const V extends string, const T extends string, const R extends References = {}, const W extends boolean = false>(spec: ResourceSpec<S> & {
204
369
  vendor: V;
205
370
  type: T;
206
371
  fields: {
207
372
  references?: R;
208
373
  };
209
- }): Resource<S, `${V}.${T}`, R>;
374
+ writable?: W;
375
+ }): Resource<S, `${V}.${T}`, R, W>;
210
376
  /** Every resource type the connectors declare, by `<vendor>.<type>`. */
211
377
  export declare function resourceTypesOf(connectors: readonly Connector<any, any>[]): Map<string, Resource>;
212
378
  export {};