@dashai/sdk 0.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -13
- package/dist/auth/client.cjs +23 -1
- package/dist/auth/client.cjs.map +1 -1
- package/dist/auth/client.d.cts +30 -5
- package/dist/auth/client.d.ts +30 -5
- package/dist/auth/client.js +23 -1
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/middleware.cjs +11 -1
- package/dist/auth/middleware.cjs.map +1 -1
- package/dist/auth/middleware.js +11 -1
- package/dist/auth/middleware.js.map +1 -1
- package/dist/auth/server.cjs +36 -7
- package/dist/auth/server.cjs.map +1 -1
- package/dist/auth/server.js +36 -7
- package/dist/auth/server.js.map +1 -1
- package/dist/auth/types.cjs.map +1 -1
- package/dist/auth/types.d.cts +13 -0
- package/dist/auth/types.d.ts +13 -0
- package/dist/auth/types.js.map +1 -1
- package/dist/deps/index.cjs +82 -7
- package/dist/deps/index.cjs.map +1 -1
- package/dist/deps/index.d.cts +28 -10
- package/dist/deps/index.d.ts +28 -10
- package/dist/deps/index.js +81 -8
- package/dist/deps/index.js.map +1 -1
- package/dist/index-BsSFz58g.d.cts +431 -0
- package/dist/index-BsSFz58g.d.ts +431 -0
- package/dist/index.cjs +318 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -53
- package/dist/index.d.ts +66 -53
- package/dist/index.js +313 -26
- package/dist/index.js.map +1 -1
- package/dist/query/index.cjs +158 -2
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +7 -7
- package/dist/query/index.d.ts +7 -7
- package/dist/query/index.js +158 -2
- package/dist/query/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/{types-DXsbCVkb.d.cts → types-CkAfiS4k.d.cts} +106 -38
- package/dist/{types-DXsbCVkb.d.ts → types-CkAfiS4k.d.ts} +106 -38
- package/dist/uses/index.cjs +147 -0
- package/dist/uses/index.cjs.map +1 -0
- package/dist/uses/index.d.cts +1 -0
- package/dist/uses/index.d.ts +1 -0
- package/dist/uses/index.js +142 -0
- package/dist/uses/index.js.map +1 -0
- package/package.json +6 -1
- package/dist/errors-BV75u7b9.d.cts +0 -207
- package/dist/errors-BV75u7b9.d.ts +0 -207
package/dist/query/index.cjs
CHANGED
|
@@ -18,6 +18,44 @@ var DashwiseErrorCode = {
|
|
|
18
18
|
TABLE_NOT_IN_CONTRACT: "TABLE_NOT_IN_CONTRACT",
|
|
19
19
|
PROVIDER_TABLE_MISSING: "PROVIDER_TABLE_MISSING",
|
|
20
20
|
OPERATION_NOT_ALLOWED_BY_PROVIDER: "OPERATION_NOT_ALLOWED_BY_PROVIDER",
|
|
21
|
+
// Cross-module dependency PARK state (Phase 3 modules-platform-v2 —
|
|
22
|
+
// dependency connect/bind lifecycle). Surfaced at RUNTIME (409) when a
|
|
23
|
+
// module reads a borrowed table (`client.deps(slug)` / `qb.deps.<slug>`)
|
|
24
|
+
// or invokes a dep action whose `module_dependencies` row is currently
|
|
25
|
+
// `status='unbound'` — the dependency is declared but not connected to a
|
|
26
|
+
// provider installation (no provider in the workspace, version mismatch,
|
|
27
|
+
// manually unbound, provider uninstalled, etc.). The consumer app should
|
|
28
|
+
// render a "connect your provider" state rather than treating this as a
|
|
29
|
+
// hard failure. `err.context` carries `{ provider, range, reason }`.
|
|
30
|
+
DEP_UNBOUND: "DEP_UNBOUND",
|
|
31
|
+
// Workspace-table `uses` plane (Phase 4 modules-platform-v2 — the
|
|
32
|
+
// declared/portable path for a module to read+write a WORKSPACE table
|
|
33
|
+
// the workspace already owns, as opposed to `deps` = another module's
|
|
34
|
+
// tables). Surfaced at RUNTIME against `client.uses(slug)` /
|
|
35
|
+
// `qb.uses.<slug>` / the `POST /api/module-api/uses/:slug/...` REST
|
|
36
|
+
// plane. The BINDING is the grant on this plane (for sandbox AND
|
|
37
|
+
// api_key auth alike — a kind-local key does NOT bypass it):
|
|
38
|
+
// - USES_UNBOUND 409 — the `uses` slot is declared but its
|
|
39
|
+
// `module_table_bindings` row isn't `status='bound'` (never bound,
|
|
40
|
+
// ambiguous match, no match, table trashed, ops widened pending
|
|
41
|
+
// re-consent, manually unbound). `err.context` carries
|
|
42
|
+
// `{ uses_slug, reason }`. Recoverable: a workspace admin binds a
|
|
43
|
+
// table (`dashwise bind <uses_slug>`), then the read succeeds.
|
|
44
|
+
// - USES_OP_NOT_ALLOWED 403 — the operation isn't in the binding's
|
|
45
|
+
// enforcement set (manifest `ops` ∩ `consented_ops`). `err.context`
|
|
46
|
+
// carries `{ uses_slug, op }`. Fix: widen the manifest ops +
|
|
47
|
+
// re-consent (re-bind), or the admin re-binds to consent.
|
|
48
|
+
// - CONTRACT_FIELD_MISSING 409 — a field the binding maps no longer
|
|
49
|
+
// exists on the physical table (schema drift). `err.context`
|
|
50
|
+
// carries `{ uses_slug, field }`. The binding is best-effort parked
|
|
51
|
+
// on detection; an admin re-binds to a table that has the field.
|
|
52
|
+
USES_UNBOUND: "USES_UNBOUND",
|
|
53
|
+
USES_OP_NOT_ALLOWED: "USES_OP_NOT_ALLOWED",
|
|
54
|
+
CONTRACT_FIELD_MISSING: "CONTRACT_FIELD_MISSING",
|
|
55
|
+
// `uses`-plane query joins are NOT supported in v1 — a
|
|
56
|
+
// `qb.uses.<slug>.join(...)` / cross-plane join is rejected with a
|
|
57
|
+
// typed 400. (Joins WITH a uses table as a target are v2 territory.)
|
|
58
|
+
USES_JOIN_UNSUPPORTED: "USES_JOIN_UNSUPPORTED",
|
|
21
59
|
// Query-plane joins (Phase 3 — see
|
|
22
60
|
// dashwise-devops-docs/plans/modules-sdk-query-v1-p3-execution.md).
|
|
23
61
|
// Surfaced when `.join('<slug>')` / `.leftJoin('<slug>')` can't
|
|
@@ -30,8 +68,8 @@ var DashwiseErrorCode = {
|
|
|
30
68
|
// Cross-module actions (Phase 7 slice 7.3a — see
|
|
31
69
|
// dashwise-devops-docs/plans/modules-sdk-query-v1-p7-cross-module-writes.md).
|
|
32
70
|
// Surfaced when `qb.deps.<dep>.actions.<name>(input)` (generated
|
|
33
|
-
// factory) dispatches against the
|
|
34
|
-
// `POST
|
|
71
|
+
// factory) dispatches against the backend endpoint
|
|
72
|
+
// `POST /api/module-api/deps/:providerSlug/actions/:actionName`.
|
|
35
73
|
// Slice 7.2b ships the backend emitter; slice 7.3a (this slice)
|
|
36
74
|
// reserves the codes + maps them to DepActionError in the SDK.
|
|
37
75
|
ACTION_NOT_EXPOSED: "ACTION_NOT_EXPOSED",
|
|
@@ -135,6 +173,112 @@ var OperationNotAllowedByProviderError = class extends DashwiseError {
|
|
|
135
173
|
});
|
|
136
174
|
}
|
|
137
175
|
};
|
|
176
|
+
var DepUnboundError = class extends DashwiseError {
|
|
177
|
+
constructor(message, context, requestId = null) {
|
|
178
|
+
super(DashwiseErrorCode.DEP_UNBOUND, message, {
|
|
179
|
+
status: 409,
|
|
180
|
+
context,
|
|
181
|
+
requestId
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The provider module slug the parked dependency points at (kebab-case,
|
|
186
|
+
* e.g. `crm`). Read from `context.provider`; `undefined` if the backend
|
|
187
|
+
* omitted it.
|
|
188
|
+
*/
|
|
189
|
+
get provider() {
|
|
190
|
+
const v = this.context?.provider;
|
|
191
|
+
return typeof v === "string" ? v : void 0;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The SemVer range the consumer's manifest declared for this dependency
|
|
195
|
+
* (e.g. `^1.2.0`). Read from `context.range`; `undefined` if omitted.
|
|
196
|
+
*/
|
|
197
|
+
get range() {
|
|
198
|
+
const v = this.context?.range;
|
|
199
|
+
return typeof v === "string" ? v : void 0;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Why the dependency is unbound — one of {@link DepUnboundReason} (but
|
|
203
|
+
* typed as `string` for forward-compat with reasons the backend may add).
|
|
204
|
+
* Read from `context.reason`; `undefined` if omitted.
|
|
205
|
+
*/
|
|
206
|
+
get reason() {
|
|
207
|
+
const v = this.context?.reason;
|
|
208
|
+
return typeof v === "string" ? v : void 0;
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
var UsesUnboundError = class extends DashwiseError {
|
|
212
|
+
constructor(message, context, requestId = null) {
|
|
213
|
+
super(DashwiseErrorCode.USES_UNBOUND, message, {
|
|
214
|
+
status: 409,
|
|
215
|
+
context,
|
|
216
|
+
requestId
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The manifest `uses[].tables[].slug` of the unbound slot (kebab-case,
|
|
221
|
+
* e.g. `employees`). Read from `context.uses_slug`; `undefined` if the
|
|
222
|
+
* backend omitted it.
|
|
223
|
+
*/
|
|
224
|
+
get usesSlug() {
|
|
225
|
+
const v = this.context?.uses_slug;
|
|
226
|
+
return typeof v === "string" ? v : void 0;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Why the slot is unbound — one of {@link UsesUnboundReason} (typed as
|
|
230
|
+
* `string` for forward-compat with reasons the backend may add). Read
|
|
231
|
+
* from `context.reason`; `undefined` if omitted.
|
|
232
|
+
*/
|
|
233
|
+
get reason() {
|
|
234
|
+
const v = this.context?.reason;
|
|
235
|
+
return typeof v === "string" ? v : void 0;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
var UsesOpNotAllowedError = class extends DashwiseError {
|
|
239
|
+
constructor(message, context, requestId = null) {
|
|
240
|
+
super(DashwiseErrorCode.USES_OP_NOT_ALLOWED, message, {
|
|
241
|
+
status: 403,
|
|
242
|
+
context,
|
|
243
|
+
requestId
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/** The `uses` slot slug the rejected op targeted. Read from `context.uses_slug`. */
|
|
247
|
+
get usesSlug() {
|
|
248
|
+
const v = this.context?.uses_slug;
|
|
249
|
+
return typeof v === "string" ? v : void 0;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The operation that was rejected — one of `create` / `read` /
|
|
253
|
+
* `update` / `delete`. Read from `context.op`; `undefined` if omitted.
|
|
254
|
+
*/
|
|
255
|
+
get op() {
|
|
256
|
+
const v = this.context?.op;
|
|
257
|
+
return typeof v === "string" ? v : void 0;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var ContractFieldMissingError = class extends DashwiseError {
|
|
261
|
+
constructor(message, context, requestId = null) {
|
|
262
|
+
super(DashwiseErrorCode.CONTRACT_FIELD_MISSING, message, {
|
|
263
|
+
status: 409,
|
|
264
|
+
context,
|
|
265
|
+
requestId
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/** The `uses` slot slug whose contract broke. Read from `context.uses_slug`. */
|
|
269
|
+
get usesSlug() {
|
|
270
|
+
const v = this.context?.uses_slug;
|
|
271
|
+
return typeof v === "string" ? v : void 0;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The declared field slug (the `uses` side name) whose mapped physical
|
|
275
|
+
* field is gone. Read from `context.field`; `undefined` if omitted.
|
|
276
|
+
*/
|
|
277
|
+
get field() {
|
|
278
|
+
const v = this.context?.field;
|
|
279
|
+
return typeof v === "string" ? v : void 0;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
138
282
|
var JoinError = class extends DashwiseError {
|
|
139
283
|
constructor(code, message, context, requestId = null) {
|
|
140
284
|
super(code, message, { status: 400, context, requestId });
|
|
@@ -176,9 +320,21 @@ function fromBackendEnvelope(status, envelope, requestId = null) {
|
|
|
176
320
|
return new ProviderTableMissingError(message, context, requestId);
|
|
177
321
|
case DashwiseErrorCode.OPERATION_NOT_ALLOWED_BY_PROVIDER:
|
|
178
322
|
return new OperationNotAllowedByProviderError(message, context, requestId);
|
|
323
|
+
case DashwiseErrorCode.DEP_UNBOUND:
|
|
324
|
+
return new DepUnboundError(message, context, requestId);
|
|
325
|
+
case DashwiseErrorCode.USES_UNBOUND:
|
|
326
|
+
return new UsesUnboundError(message, context, requestId);
|
|
327
|
+
case DashwiseErrorCode.USES_OP_NOT_ALLOWED:
|
|
328
|
+
return new UsesOpNotAllowedError(message, context, requestId);
|
|
329
|
+
case DashwiseErrorCode.CONTRACT_FIELD_MISSING:
|
|
330
|
+
return new ContractFieldMissingError(message, context, requestId);
|
|
179
331
|
case DashwiseErrorCode.LINK_FIELD_NOT_FOUND:
|
|
180
332
|
case DashwiseErrorCode.NOT_A_LINK_FIELD:
|
|
181
333
|
case DashwiseErrorCode.JOIN_NOT_LINKED:
|
|
334
|
+
// `uses`-plane joins are unsupported in v1; the backend emits a 400
|
|
335
|
+
// with this code. Map to JoinError so it lands in the same
|
|
336
|
+
// "your join can't be resolved" family (code preserved for `err.code`).
|
|
337
|
+
case DashwiseErrorCode.USES_JOIN_UNSUPPORTED:
|
|
182
338
|
return new JoinError(code, message, context, requestId);
|
|
183
339
|
case DashwiseErrorCode.ACTION_NOT_EXPOSED:
|
|
184
340
|
case DashwiseErrorCode.ACTION_NOT_DECLARED:
|