@tier0/sdk-v2 0.0.0-stage → 0.2.1
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/LICENSE +21 -0
- package/NOTICE.md +7 -0
- package/README.md +201 -2
- package/dist/cjs/app-identity-contract.generated.d.ts +22 -0
- package/dist/cjs/app-identity-contract.generated.js +51 -0
- package/dist/cjs/app-identity-contract.generated.js.map +1 -0
- package/dist/cjs/capabilities.d.ts +54 -0
- package/dist/cjs/capabilities.js +134 -0
- package/dist/cjs/capabilities.js.map +1 -0
- package/dist/cjs/client.d.ts +604 -0
- package/dist/cjs/client.js +35 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/cloud-server.d.ts +31 -0
- package/dist/cjs/cloud-server.js +114 -0
- package/dist/cjs/cloud-server.js.map +1 -0
- package/dist/cjs/cloud-transport.d.ts +67 -0
- package/dist/cjs/cloud-transport.js +272 -0
- package/dist/cjs/cloud-transport.js.map +1 -0
- package/dist/cjs/controls.d.ts +93 -0
- package/dist/cjs/controls.js +169 -0
- package/dist/cjs/controls.js.map +1 -0
- package/dist/cjs/data/bootstrap.d.ts +70 -0
- package/dist/cjs/data/bootstrap.js +291 -0
- package/dist/cjs/data/bootstrap.js.map +1 -0
- package/dist/cjs/data/call.d.ts +33 -0
- package/dist/cjs/data/call.js +216 -0
- package/dist/cjs/data/call.js.map +1 -0
- package/dist/cjs/data/client.d.ts +134 -0
- package/dist/cjs/data/client.js +185 -0
- package/dist/cjs/data/client.js.map +1 -0
- package/dist/cjs/data/collection.d.ts +335 -0
- package/dist/cjs/data/collection.js +601 -0
- package/dist/cjs/data/collection.js.map +1 -0
- package/dist/cjs/data/context.d.ts +12 -0
- package/dist/cjs/data/context.js +50 -0
- package/dist/cjs/data/context.js.map +1 -0
- package/dist/cjs/data/declarations.d.ts +11 -0
- package/dist/cjs/data/declarations.js +18 -0
- package/dist/cjs/data/declarations.js.map +1 -0
- package/dist/cjs/data/define.d.ts +77 -0
- package/dist/cjs/data/define.js +31 -0
- package/dist/cjs/data/define.js.map +1 -0
- package/dist/cjs/data/error.d.ts +78 -0
- package/dist/cjs/data/error.js +182 -0
- package/dist/cjs/data/error.js.map +1 -0
- package/dist/cjs/data/index.d.ts +24 -0
- package/dist/cjs/data/index.js +49 -0
- package/dist/cjs/data/index.js.map +1 -0
- package/dist/cjs/data/schema.d.ts +88 -0
- package/dist/cjs/data/schema.js +657 -0
- package/dist/cjs/data/schema.js.map +1 -0
- package/dist/cjs/data/sort.d.ts +8 -0
- package/dist/cjs/data/sort.js +21 -0
- package/dist/cjs/data/sort.js.map +1 -0
- package/dist/cjs/data/subscribe.d.ts +108 -0
- package/dist/cjs/data/subscribe.js +270 -0
- package/dist/cjs/data/subscribe.js.map +1 -0
- package/dist/cjs/files.d.ts +67 -0
- package/dist/cjs/files.js +119 -0
- package/dist/cjs/files.js.map +1 -0
- package/dist/cjs/framework-scope.d.ts +1 -0
- package/dist/cjs/framework-scope.js +14 -0
- package/dist/cjs/framework-scope.js.map +1 -0
- package/dist/cjs/index.d.ts +14 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mq/broker.d.ts +65 -0
- package/dist/cjs/mq/broker.js +115 -0
- package/dist/cjs/mq/broker.js.map +1 -0
- package/dist/cjs/mq/client.d.ts +37 -0
- package/dist/cjs/mq/client.js +321 -0
- package/dist/cjs/mq/client.js.map +1 -0
- package/dist/cjs/mq/index.d.ts +5 -0
- package/dist/cjs/mq/index.js +11 -0
- package/dist/cjs/mq/index.js.map +1 -0
- package/dist/cjs/mq/types.d.ts +48 -0
- package/dist/cjs/mq/types.js +3 -0
- package/dist/cjs/mq/types.js.map +1 -0
- package/dist/cjs/openapi/api.generated.d.ts +820 -0
- package/dist/cjs/openapi/api.generated.js +607 -0
- package/dist/cjs/openapi/api.generated.js.map +1 -0
- package/dist/cjs/openapi/client.d.ts +56 -0
- package/dist/cjs/openapi/client.js +219 -0
- package/dist/cjs/openapi/client.js.map +1 -0
- package/dist/cjs/openapi/codecs.generated.d.ts +2234 -0
- package/dist/cjs/openapi/codecs.generated.js +6 -0
- package/dist/cjs/openapi/codecs.generated.js.map +1 -0
- package/dist/cjs/openapi/index.d.ts +5 -0
- package/dist/cjs/openapi/index.js +12 -0
- package/dist/cjs/openapi/index.js.map +1 -0
- package/dist/cjs/openapi/types.generated.d.ts +3227 -0
- package/dist/cjs/openapi/types.generated.js +3 -0
- package/dist/cjs/openapi/types.generated.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/react.d.ts +9 -0
- package/dist/cjs/react.js +16 -0
- package/dist/cjs/react.js.map +1 -0
- package/dist/cjs/runtime-context.d.ts +9 -0
- package/dist/cjs/runtime-context.js +25 -0
- package/dist/cjs/runtime-context.js.map +1 -0
- package/dist/cjs/runtime-env.d.ts +1 -0
- package/dist/cjs/runtime-env.js +18 -0
- package/dist/cjs/runtime-env.js.map +1 -0
- package/dist/cjs/source.d.ts +39 -0
- package/dist/cjs/source.js +29 -0
- package/dist/cjs/source.js.map +1 -0
- package/dist/cjs/stream.d.ts +40 -0
- package/dist/cjs/stream.js +33 -0
- package/dist/cjs/stream.js.map +1 -0
- package/dist/cjs/uns-v2/client.d.ts +132 -0
- package/dist/cjs/uns-v2/client.js +352 -0
- package/dist/cjs/uns-v2/client.js.map +1 -0
- package/dist/cjs/uns-v2/codec.d.ts +11 -0
- package/dist/cjs/uns-v2/codec.js +290 -0
- package/dist/cjs/uns-v2/codec.js.map +1 -0
- package/dist/cjs/uns-v2/data-client.d.ts +10 -0
- package/dist/cjs/uns-v2/data-client.js +18 -0
- package/dist/cjs/uns-v2/data-client.js.map +1 -0
- package/dist/cjs/uns-v2/generated.d.ts +18178 -0
- package/dist/cjs/uns-v2/generated.js +144 -0
- package/dist/cjs/uns-v2/generated.js.map +1 -0
- package/dist/cjs/uns-v2/index.d.ts +5 -0
- package/dist/cjs/uns-v2/index.js +24 -0
- package/dist/cjs/uns-v2/index.js.map +1 -0
- package/dist/cjs/uns-v2/sse.d.ts +20 -0
- package/dist/cjs/uns-v2/sse.js +65 -0
- package/dist/cjs/uns-v2/sse.js.map +1 -0
- package/dist/cjs/vue.d.ts +9 -0
- package/dist/cjs/vue.js +39 -0
- package/dist/cjs/vue.js.map +1 -0
- package/dist/esm/app-identity-contract.generated.d.ts +22 -0
- package/dist/esm/app-identity-contract.generated.js +48 -0
- package/dist/esm/app-identity-contract.generated.js.map +1 -0
- package/dist/esm/capabilities.d.ts +54 -0
- package/dist/esm/capabilities.js +129 -0
- package/dist/esm/capabilities.js.map +1 -0
- package/dist/esm/client.d.ts +604 -0
- package/dist/esm/client.js +32 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/cloud-server.d.ts +31 -0
- package/dist/esm/cloud-server.js +109 -0
- package/dist/esm/cloud-server.js.map +1 -0
- package/dist/esm/cloud-transport.d.ts +67 -0
- package/dist/esm/cloud-transport.js +267 -0
- package/dist/esm/cloud-transport.js.map +1 -0
- package/dist/esm/controls.d.ts +93 -0
- package/dist/esm/controls.js +163 -0
- package/dist/esm/controls.js.map +1 -0
- package/dist/esm/data/bootstrap.d.ts +70 -0
- package/dist/esm/data/bootstrap.js +286 -0
- package/dist/esm/data/bootstrap.js.map +1 -0
- package/dist/esm/data/call.d.ts +33 -0
- package/dist/esm/data/call.js +211 -0
- package/dist/esm/data/call.js.map +1 -0
- package/dist/esm/data/client.d.ts +134 -0
- package/dist/esm/data/client.js +181 -0
- package/dist/esm/data/client.js.map +1 -0
- package/dist/esm/data/collection.d.ts +335 -0
- package/dist/esm/data/collection.js +594 -0
- package/dist/esm/data/collection.js.map +1 -0
- package/dist/esm/data/context.d.ts +12 -0
- package/dist/esm/data/context.js +44 -0
- package/dist/esm/data/context.js.map +1 -0
- package/dist/esm/data/declarations.d.ts +11 -0
- package/dist/esm/data/declarations.js +10 -0
- package/dist/esm/data/declarations.js.map +1 -0
- package/dist/esm/data/define.d.ts +77 -0
- package/dist/esm/data/define.js +27 -0
- package/dist/esm/data/define.js.map +1 -0
- package/dist/esm/data/error.d.ts +78 -0
- package/dist/esm/data/error.js +176 -0
- package/dist/esm/data/error.js.map +1 -0
- package/dist/esm/data/index.d.ts +24 -0
- package/dist/esm/data/index.js +20 -0
- package/dist/esm/data/index.js.map +1 -0
- package/dist/esm/data/schema.d.ts +88 -0
- package/dist/esm/data/schema.js +646 -0
- package/dist/esm/data/schema.js.map +1 -0
- package/dist/esm/data/sort.d.ts +8 -0
- package/dist/esm/data/sort.js +18 -0
- package/dist/esm/data/sort.js.map +1 -0
- package/dist/esm/data/subscribe.d.ts +108 -0
- package/dist/esm/data/subscribe.js +265 -0
- package/dist/esm/data/subscribe.js.map +1 -0
- package/dist/esm/files.d.ts +67 -0
- package/dist/esm/files.js +113 -0
- package/dist/esm/files.js.map +1 -0
- package/dist/esm/framework-scope.d.ts +1 -0
- package/dist/esm/framework-scope.js +11 -0
- package/dist/esm/framework-scope.js.map +1 -0
- package/dist/esm/index.d.ts +14 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mq/broker.d.ts +65 -0
- package/dist/esm/mq/broker.js +109 -0
- package/dist/esm/mq/broker.js.map +1 -0
- package/dist/esm/mq/client.d.ts +37 -0
- package/dist/esm/mq/client.js +314 -0
- package/dist/esm/mq/client.js.map +1 -0
- package/dist/esm/mq/index.d.ts +5 -0
- package/dist/esm/mq/index.js +3 -0
- package/dist/esm/mq/index.js.map +1 -0
- package/dist/esm/mq/types.d.ts +48 -0
- package/dist/esm/mq/types.js +2 -0
- package/dist/esm/mq/types.js.map +1 -0
- package/dist/esm/openapi/api.generated.d.ts +820 -0
- package/dist/esm/openapi/api.generated.js +603 -0
- package/dist/esm/openapi/api.generated.js.map +1 -0
- package/dist/esm/openapi/client.d.ts +56 -0
- package/dist/esm/openapi/client.js +210 -0
- package/dist/esm/openapi/client.js.map +1 -0
- package/dist/esm/openapi/codecs.generated.d.ts +2234 -0
- package/dist/esm/openapi/codecs.generated.js +3 -0
- package/dist/esm/openapi/codecs.generated.js.map +1 -0
- package/dist/esm/openapi/index.d.ts +5 -0
- package/dist/esm/openapi/index.js +3 -0
- package/dist/esm/openapi/index.js.map +1 -0
- package/dist/esm/openapi/types.generated.d.ts +3227 -0
- package/dist/esm/openapi/types.generated.js +2 -0
- package/dist/esm/openapi/types.generated.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react.d.ts +9 -0
- package/dist/esm/react.js +12 -0
- package/dist/esm/react.js.map +1 -0
- package/dist/esm/runtime-context.d.ts +9 -0
- package/dist/esm/runtime-context.js +22 -0
- package/dist/esm/runtime-context.js.map +1 -0
- package/dist/esm/runtime-env.d.ts +1 -0
- package/dist/esm/runtime-env.js +15 -0
- package/dist/esm/runtime-env.js.map +1 -0
- package/dist/esm/source.d.ts +39 -0
- package/dist/esm/source.js +25 -0
- package/dist/esm/source.js.map +1 -0
- package/dist/esm/stream.d.ts +40 -0
- package/dist/esm/stream.js +29 -0
- package/dist/esm/stream.js.map +1 -0
- package/dist/esm/uns-v2/client.d.ts +132 -0
- package/dist/esm/uns-v2/client.js +343 -0
- package/dist/esm/uns-v2/client.js.map +1 -0
- package/dist/esm/uns-v2/codec.d.ts +11 -0
- package/dist/esm/uns-v2/codec.js +284 -0
- package/dist/esm/uns-v2/codec.js.map +1 -0
- package/dist/esm/uns-v2/data-client.d.ts +10 -0
- package/dist/esm/uns-v2/data-client.js +14 -0
- package/dist/esm/uns-v2/data-client.js.map +1 -0
- package/dist/esm/uns-v2/generated.d.ts +18178 -0
- package/dist/esm/uns-v2/generated.js +141 -0
- package/dist/esm/uns-v2/generated.js.map +1 -0
- package/dist/esm/uns-v2/index.d.ts +5 -0
- package/dist/esm/uns-v2/index.js +5 -0
- package/dist/esm/uns-v2/index.js.map +1 -0
- package/dist/esm/uns-v2/sse.d.ts +20 -0
- package/dist/esm/uns-v2/sse.js +60 -0
- package/dist/esm/uns-v2/sse.js.map +1 -0
- package/dist/esm/vue.d.ts +9 -0
- package/dist/esm/vue.js +36 -0
- package/dist/esm/vue.js.map +1 -0
- package/docs/acceptance-2026-10-22.md +88 -0
- package/package.json +243 -4
- package/skills/tier0-sdk-v2/SKILL.md +66 -0
- package/skills/tier0-sdk-v2/references/integration.md +72 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-agent/SKILL.md +73 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-agent/references/results.md +45 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-controls/SKILL.md +63 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/SKILL.md +58 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/consistency.md +70 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/errors.md +82 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/modeling.md +113 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/read-write.md +168 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/schema-evolution.md +36 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/SKILL.md +85 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/delete.md +22 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/download.md +49 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/multipart.md +42 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/upload.md +27 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-files/references/url.md +22 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/SKILL.md +56 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/app-members.md +41 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/platform-members.md +56 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/SKILL.md +78 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/references/quickstart.md +69 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/SKILL.md +42 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/get.md +34 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/send.md +72 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +38 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/changes.md +40 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +63 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/delete.md +47 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/protocols.md +36 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/read.md +34 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/state.md +37 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/update.md +62 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +43 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +56 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/delete.md +35 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +64 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/lifecycle.md +26 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/read.md +35 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/update.md +36 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/SKILL.md +64 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/references/info.md +23 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-system/references/whoami.md +21 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/SKILL.md +55 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/create.md +56 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/data-workflows.md +69 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/delete.md +53 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/namespace.md +38 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/read.md +34 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/restore.md +39 -0
- package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/update.md +62 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataError = exports.ACCESS_REASONS = void 0;
|
|
4
|
+
exports.appStatus = appStatus;
|
|
5
|
+
exports.toDataError = toDataError;
|
|
6
|
+
/**
|
|
7
|
+
* Stable `data.reason` codes UNS adds when it refuses App data access; the
|
|
8
|
+
* top-level code stays FORBIDDEN / NOT_FOUND. Only whole-request errors carry
|
|
9
|
+
* them, never per-item results of a batch or transaction.
|
|
10
|
+
*/
|
|
11
|
+
exports.ACCESS_REASONS = {
|
|
12
|
+
/** 403: the collection exists, but this App's grant does not cover it or the operation. */
|
|
13
|
+
notGranted: 'COLLECTION_NOT_GRANTED',
|
|
14
|
+
/** 403 or 404: the collection is gone (hard-deleted or archived). */
|
|
15
|
+
notFound: 'COLLECTION_NOT_FOUND',
|
|
16
|
+
/** 403: the grant covers the operation, the App key lacks `data.missingPermission`. */
|
|
17
|
+
permissionMissing: 'APP_PERMISSION_MISSING',
|
|
18
|
+
};
|
|
19
|
+
class DataError extends Error {
|
|
20
|
+
/** HTTP status the App should answer with (see `appStatus`). */
|
|
21
|
+
status;
|
|
22
|
+
/** UNS error code, e.g. `DUPLICATE_KEY`, or a data-layer code. */
|
|
23
|
+
code;
|
|
24
|
+
/** Stable `data.reason` code, e.g. `COLLECTION_NOT_FOUND` (see ACCESS_REASONS). */
|
|
25
|
+
reason;
|
|
26
|
+
/** HTTP status UNS answered with; 0 when no response arrived. */
|
|
27
|
+
upstreamStatus;
|
|
28
|
+
requestId;
|
|
29
|
+
/**
|
|
30
|
+
* How far the failed request got: `notStarted` / `rolledBack` changed
|
|
31
|
+
* nothing, `committed` took effect, `unknown` (writes only) may have.
|
|
32
|
+
* Data-layer refusals raised before sending are `notStarted`.
|
|
33
|
+
*/
|
|
34
|
+
execution;
|
|
35
|
+
/** Whether the same call may be repeated later, and after how long. The data layer already retried it. */
|
|
36
|
+
retry;
|
|
37
|
+
/** `execution === "unknown"`: a write may have landed. Read back before writing again. */
|
|
38
|
+
outcomeUnknown;
|
|
39
|
+
/** Requests sent for this call, retries included; 0 when nothing was sent. */
|
|
40
|
+
attempts;
|
|
41
|
+
/**
|
|
42
|
+
* The idempotency key the write was sent with (generated unless the caller
|
|
43
|
+
* gave one). After `outcomeUnknown`, sending the same write with this key
|
|
44
|
+
* again cannot apply it twice.
|
|
45
|
+
*/
|
|
46
|
+
idempotencyKey;
|
|
47
|
+
/** The `data` object of the UNS error envelope, or data-layer details. */
|
|
48
|
+
details;
|
|
49
|
+
constructor(init) {
|
|
50
|
+
super(init.message, init.cause === undefined ? undefined : { cause: init.cause });
|
|
51
|
+
this.name = 'DataError';
|
|
52
|
+
this.status = init.status;
|
|
53
|
+
this.code = init.code;
|
|
54
|
+
this.reason = init.reason;
|
|
55
|
+
this.upstreamStatus = init.upstreamStatus ?? 0;
|
|
56
|
+
this.requestId = init.requestId;
|
|
57
|
+
this.execution = init.execution ?? 'notStarted';
|
|
58
|
+
this.retry = init.retry ?? { safe: false };
|
|
59
|
+
this.outcomeUnknown = this.execution === 'unknown';
|
|
60
|
+
this.attempts = init.attempts ?? 0;
|
|
61
|
+
this.idempotencyKey = init.idempotencyKey;
|
|
62
|
+
this.details = init.details ?? {};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.DataError = DataError;
|
|
66
|
+
/** Platform states the App's caller cannot fix: they answer 503 whatever UNS answered. */
|
|
67
|
+
const PLATFORM_CODES = new Set(['APP_NOT_READY', 'DEPENDENCY_UNAVAILABLE', 'CREDENTIAL_CHANGED', 'OUTCOME_UNKNOWN', 'TEMPORARILY_UNAVAILABLE']);
|
|
68
|
+
/**
|
|
69
|
+
* Maps an upstream UNS status and code to the status the App answers its own
|
|
70
|
+
* caller with. Credential failures are the platform's problem, not the user's
|
|
71
|
+
* session, so a 401 from UNS becomes 502 instead of looking like a logout;
|
|
72
|
+
* platform states (App not ready yet, a dependency down, the App key changed
|
|
73
|
+
* mid-request) become 503 instead of looking like a denied action or a conflict.
|
|
74
|
+
*/
|
|
75
|
+
function appStatus(upstream, code = '') {
|
|
76
|
+
if (upstream === 401)
|
|
77
|
+
return 502;
|
|
78
|
+
if (PLATFORM_CODES.has(code))
|
|
79
|
+
return 503;
|
|
80
|
+
if (upstream === 400 || upstream === 403 || upstream === 404 || upstream === 409 || upstream === 413 || upstream === 422 || upstream === 429) {
|
|
81
|
+
return upstream;
|
|
82
|
+
}
|
|
83
|
+
if (upstream === 502 || upstream === 503 || upstream === 504)
|
|
84
|
+
return 503;
|
|
85
|
+
if (upstream >= 500)
|
|
86
|
+
return 502;
|
|
87
|
+
return upstream >= 400 ? 400 : 502;
|
|
88
|
+
}
|
|
89
|
+
const CODE_HINTS = {
|
|
90
|
+
UPSERT_REQUIRES_UNIQUE_INDEX: 'An upsert filter must contain `_id` or every field of a unique index that is already ready; a newly declared unique index may still be building.',
|
|
91
|
+
DUPLICATE_KEY: 'A unique index already holds this value. (From restore: an active record took the value meanwhile; nothing was restored.)',
|
|
92
|
+
VERSION_CONFLICT: 'The record changed since it was read; reload it and retry with the new revision.',
|
|
93
|
+
APP_GRANT_REVOKED: "A workspace admin revoked this App's access to the collection; it is not re-granted automatically. Ask the admin to restore the grant.",
|
|
94
|
+
INDEX_QUOTA_EXCEEDED: 'The workspace index quota (200, counting every index that physically exists) is exhausted. Remove unused indexes through the tier0 MCP.',
|
|
95
|
+
COLLECTION_TOO_LARGE: 'archive / restore handle at most 2000 records; stop using a large collection in code instead of archiving it.',
|
|
96
|
+
OVERLOADED: "This workspace's data requests are over their concurrency share; the data layer already waited and retried. Batch page reads with data.queryBatch and avoid per-record loops.",
|
|
97
|
+
APP_NOT_READY: 'The platform is still preparing this App (e.g. right after an import); retry shortly.',
|
|
98
|
+
QUERY_TIMEOUT: 'Narrow the query: add an indexed condition, a smaller limit or maxCount.',
|
|
99
|
+
OUTCOME_UNKNOWN: 'The write may have committed; read the record back before writing again.',
|
|
100
|
+
};
|
|
101
|
+
/** `APP_QUOTA_EXCEEDED` per `data.resource`; each per-App limit is 64. */
|
|
102
|
+
const QUOTA_HINTS = {
|
|
103
|
+
collections: 'This App owns 64 active collections. Archive unused ones through the tier0 MCP.',
|
|
104
|
+
indexes: "This App's collections hold 64 indexes. Drop unused indexes from the declarations, then apply that with schema:replace through the tier0 MCP.",
|
|
105
|
+
archivedCollections: 'This App keeps 64 archived collections. Restore one, or ask a workspace admin to clean up archived collections.',
|
|
106
|
+
};
|
|
107
|
+
/** SDK transport failures: no UNS answer to map, so the data layer names them. */
|
|
108
|
+
const TRANSPORT_FAILURES = {
|
|
109
|
+
UNS_V2_TRANSPORT_TIMEOUT: { code: 'DATA_TIMEOUT', status: 503, message: 'UNS did not answer in time' },
|
|
110
|
+
UNS_V2_TRANSPORT_ERROR: { code: 'DATA_UNREACHABLE', status: 503, message: 'Cannot reach the Tier0 data service' },
|
|
111
|
+
// The business request was aborted while the call was in flight (499: client closed request).
|
|
112
|
+
UNS_V2_TRANSPORT_ABORTED: { code: 'DATA_ABORTED', status: 499, message: 'The data call was aborted' },
|
|
113
|
+
UNS_V2_PROTOCOL_ERROR: { code: 'DATA_BAD_RESPONSE', status: 502, message: 'UNS answered with an invalid response' },
|
|
114
|
+
};
|
|
115
|
+
function codeHint(code, details) {
|
|
116
|
+
if (code === 'APP_QUOTA_EXCEEDED') {
|
|
117
|
+
const resource = typeof details.resource === 'string' ? details.resource : '';
|
|
118
|
+
return QUOTA_HINTS[resource] ?? 'This App reached a collection/index quota. Remove unused collections or indexes through the tier0 MCP.';
|
|
119
|
+
}
|
|
120
|
+
return CODE_HINTS[code];
|
|
121
|
+
}
|
|
122
|
+
function isObject(value) {
|
|
123
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
124
|
+
}
|
|
125
|
+
/** Translates a failed UNS call of the SDK client after `attempts` requests, sent with `idempotencyKey`. */
|
|
126
|
+
function toDataError(error, attempts = 1, idempotencyKey) {
|
|
127
|
+
const common = {
|
|
128
|
+
upstreamStatus: error.status,
|
|
129
|
+
requestId: error.requestId,
|
|
130
|
+
execution: error.execution,
|
|
131
|
+
retry: error.retry,
|
|
132
|
+
attempts,
|
|
133
|
+
idempotencyKey,
|
|
134
|
+
cause: error,
|
|
135
|
+
};
|
|
136
|
+
const unknown = error.outcomeUnknown ? '; the write outcome is unknown' : '';
|
|
137
|
+
// An ingress or load balancer answers 502/503/504 without the UNS envelope during
|
|
138
|
+
// rolling releases and pod restarts, like any unavailable upstream. UNS v2 routes
|
|
139
|
+
// answer every other error with the envelope (401/403/429 included), so other
|
|
140
|
+
// unenveloped responses stay DATA_BAD_RESPONSE.
|
|
141
|
+
if (error.code === 'UNS_V2_PROTOCOL_ERROR' && (error.status === 502 || error.status === 503 || error.status === 504)) {
|
|
142
|
+
return new DataError({
|
|
143
|
+
...common,
|
|
144
|
+
message: `The Tier0 data gateway answered ${error.operation} with HTTP ${error.status}${unknown}.`,
|
|
145
|
+
status: 503,
|
|
146
|
+
code: `HTTP_${error.status}`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const transport = TRANSPORT_FAILURES[error.code];
|
|
150
|
+
if (transport) {
|
|
151
|
+
return new DataError({ ...common, message: `${transport.message} (${error.operation})${unknown}.`, status: transport.status, code: transport.code });
|
|
152
|
+
}
|
|
153
|
+
const httpStatus = error.status ?? 0;
|
|
154
|
+
const data = isObject(error.data) ? error.data : {};
|
|
155
|
+
// Only `data.reason` is a code; `error.reason` repeats the message text.
|
|
156
|
+
const reason = typeof data.reason === 'string' ? data.reason : undefined;
|
|
157
|
+
const code = error.code;
|
|
158
|
+
const msg = error.message;
|
|
159
|
+
const hint = codeHint(code, data) ?? error.repair;
|
|
160
|
+
let message = `${msg} (${code})`;
|
|
161
|
+
if (reason === exports.ACCESS_REASONS.permissionMissing) {
|
|
162
|
+
message =
|
|
163
|
+
data.missingPermission === 'uns.delete'
|
|
164
|
+
? `Deleting records requires the App key to hold uns.delete, and this App's key does not (${code}). ` +
|
|
165
|
+
'Model removal as a status change such as `archived`, or ask a workspace admin to grant uns.delete.'
|
|
166
|
+
: `The App key lacks ${typeof data.missingPermission === 'string' ? data.missingPermission : 'a permission'} for this operation (${code}); ask a workspace admin.`;
|
|
167
|
+
}
|
|
168
|
+
else if (reason === exports.ACCESS_REASONS.notGranted) {
|
|
169
|
+
message = `${message} This App's grant does not cover the collection or operation; ask a workspace admin to restore the grant.`;
|
|
170
|
+
}
|
|
171
|
+
else if (reason === exports.ACCESS_REASONS.notFound) {
|
|
172
|
+
message = `${message} The collection was archived or deleted; the data layer ensures the declared collections again.`;
|
|
173
|
+
}
|
|
174
|
+
else if (httpStatus === 401) {
|
|
175
|
+
message = `Tier0 rejected the App credential for ${error.operation} (${code}). The platform injects TIER0_API_KEY; do not replace it.`;
|
|
176
|
+
}
|
|
177
|
+
else if (hint) {
|
|
178
|
+
message = `${message} ${hint}`;
|
|
179
|
+
}
|
|
180
|
+
return new DataError({ ...common, message, status: appStatus(httpStatus, code), code, reason, upstreamStatus: httpStatus, details: data });
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/data/error.ts"],"names":[],"mappings":";;;AAgGA,8BASC;AAmDD,kCAqDC;AAtMD;;;;GAIG;AACU,QAAA,cAAc,GAAG;IAC5B,2FAA2F;IAC3F,UAAU,EAAE,wBAAwB;IACpC,qEAAqE;IACrE,QAAQ,EAAE,sBAAsB;IAChC,uFAAuF;IACvF,iBAAiB,EAAE,wB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OAAO,GAAG,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,OAAO,IAAI,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7I,CAAC","sourcesContent":["/**\n * Runtime failures of a data call, missing credentials included, are a\n * `DataError`. The SDK's UNS client does the HTTP exchange; its `UnsV2Error`\n * (kept as `cause`) is translated here, and the data layer raises its own codes\n * (BATCH_LIMIT_EXCEEDED, WRITE_ERRORS, ...). `status` is the HTTP status the App\n * should answer its own caller with. Writes that fail validation throw\n * `ZodError`; programming or platform errors, such as invalid client options or\n * a malformed data subject from the gateway, throw `TypeError`.\n */\nimport type { UnsV2Error, UnsV2Execution, UnsV2Retry } from '../uns-v2/client.js';\n\n/**\n * Stable `data.reason` codes UNS adds when it refuses App data access; the\n * top-level code stays FORBIDDEN / NOT_FOUND. Only whole-request errors carry\n * them, never per-item results of a batch or transaction.\n */\nexport const ACCESS_REASONS = {\n /** 403: the collection exists, but this App's grant does not cover it or the operation. */\n notGranted: 'COLLECTION_NOT_GRANTED',\n /** 403 or 404: the collection is gone (hard-deleted or archived). */\n notFound: 'COLLECTION_NOT_FOUND',\n /** 403: the grant covers the operation, the App key lacks `data.missingPermission`. */\n permissionMissing: 'APP_PERMISSION_MISSING',\n} as const;\n\nexport class DataError extends Error {\n /** HTTP status the App should answer with (see `appStatus`). */\n readonly status: number;\n /** UNS error code, e.g. `DUPLICATE_KEY`, or a data-layer code. */\n readonly code: string;\n /** Stable `data.reason` code, e.g. `COLLECTION_NOT_FOUND` (see ACCESS_REASONS). */\n readonly reason?: string;\n /** HTTP status UNS answered with; 0 when no response arrived. */\n readonly upstreamStatus: number;\n readonly requestId?: string;\n /**\n * How far the failed request got: `notStarted` / `rolledBack` changed\n * nothing, `committed` took effect, `unknown` (writes only) may have.\n * Data-layer refusals raised before sending are `notStarted`.\n */\n readonly execution: UnsV2Execution;\n /** Whether the same call may be repeated later, and after how long. The data layer already retried it. */\n readonly retry: UnsV2Retry;\n /** `execution === \"unknown\"`: a write may have landed. Read back before writing again. */\n readonly outcomeUnknown: boolean;\n /** Requests sent for this call, retries included; 0 when nothing was sent. */\n readonly attempts: number;\n /**\n * The idempotency key the write was sent with (generated unless the caller\n * gave one). After `outcomeUnknown`, sending the same write with this key\n * again cannot apply it twice.\n */\n readonly idempotencyKey?: string;\n /** The `data` object of the UNS error envelope, or data-layer details. */\n readonly details: Record<string, unknown>;\n\n constructor(init: {\n message: string;\n status: number;\n code: string;\n reason?: string;\n upstreamStatus?: number;\n requestId?: string;\n execution?: UnsV2Execution;\n retry?: UnsV2Retry;\n attempts?: number;\n idempotencyKey?: string;\n details?: Record<string, unknown>;\n cause?: unknown;\n }) {\n super(init.message, init.cause === undefined ? undefined : { cause: init.cause });\n this.name = 'DataError';\n this.status = init.status;\n this.code = init.code;\n this.reason = init.reason;\n this.upstreamStatus = init.upstreamStatus ?? 0;\n this.requestId = init.requestId;\n this.execution = init.execution ?? 'notStarted';\n this.retry = init.retry ?? { safe: false };\n this.outcomeUnknown = this.execution === 'unknown';\n this.attempts = init.attempts ?? 0;\n this.idempotencyKey = init.idempotencyKey;\n this.details = init.details ?? {};\n }\n}\n\n/** Platform states the App's caller cannot fix: they answer 503 whatever UNS answered. */\nconst PLATFORM_CODES = new Set(['APP_NOT_READY', 'DEPENDENCY_UNAVAILABLE', 'CREDENTIAL_CHANGED', 'OUTCOME_UNKNOWN', 'TEMPORARILY_UNAVAILABLE']);\n\n/**\n * Maps an upstream UNS status and code to the status the App answers its own\n * caller with. Credential failures are the platform's problem, not the user's\n * session, so a 401 from UNS becomes 502 instead of looking like a logout;\n * platform states (App not ready yet, a dependency down, the App key changed\n * mid-request) become 503 instead of looking like a denied action or a conflict.\n */\nexport function appStatus(upstream: number, code = ''): number {\n if (upstream === 401) return 502;\n if (PLATFORM_CODES.has(code)) return 503;\n if (upstream === 400 || upstream === 403 || upstream === 404 || upstream === 409 || upstream === 413 || upstream === 422 || upstream === 429) {\n return upstream;\n }\n if (upstream === 502 || upstream === 503 || upstream === 504) return 503;\n if (upstream >= 500) return 502;\n return upstream >= 400 ? 400 : 502;\n}\n\nconst CODE_HINTS: Record<string, string> = {\n UPSERT_REQUIRES_UNIQUE_INDEX:\n 'An upsert filter must contain `_id` or every field of a unique index that is already ready; a newly declared unique index may still be building.',\n DUPLICATE_KEY:\n 'A unique index already holds this value. (From restore: an active record took the value meanwhile; nothing was restored.)',\n VERSION_CONFLICT: 'The record changed since it was read; reload it and retry with the new revision.',\n APP_GRANT_REVOKED:\n \"A workspace admin revoked this App's access to the collection; it is not re-granted automatically. Ask the admin to restore the grant.\",\n INDEX_QUOTA_EXCEEDED:\n 'The workspace index quota (200, counting every index that physically exists) is exhausted. Remove unused indexes through the tier0 MCP.',\n COLLECTION_TOO_LARGE:\n 'archive / restore handle at most 2000 records; stop using a large collection in code instead of archiving it.',\n OVERLOADED:\n \"This workspace's data requests are over their concurrency share; the data layer already waited and retried. Batch page reads with data.queryBatch and avoid per-record loops.\",\n APP_NOT_READY: 'The platform is still preparing this App (e.g. right after an import); retry shortly.',\n QUERY_TIMEOUT: 'Narrow the query: add an indexed condition, a smaller limit or maxCount.',\n OUTCOME_UNKNOWN: 'The write may have committed; read the record back before writing again.',\n};\n\n/** `APP_QUOTA_EXCEEDED` per `data.resource`; each per-App limit is 64. */\nconst QUOTA_HINTS: Record<string, string> = {\n collections: 'This App owns 64 active collections. Archive unused ones through the tier0 MCP.',\n indexes: \"This App's collections hold 64 indexes. Drop unused indexes from the declarations, then apply that with schema:replace through the tier0 MCP.\",\n archivedCollections:\n 'This App keeps 64 archived collections. Restore one, or ask a workspace admin to clean up archived collections.',\n};\n\n/** SDK transport failures: no UNS answer to map, so the data layer names them. */\nconst TRANSPORT_FAILURES: Record<string, { code: string; status: number; message: string }> = {\n UNS_V2_TRANSPORT_TIMEOUT: { code: 'DATA_TIMEOUT', status: 503, message: 'UNS did not answer in time' },\n UNS_V2_TRANSPORT_ERROR: { code: 'DATA_UNREACHABLE', status: 503, message: 'Cannot reach the Tier0 data service' },\n // The business request was aborted while the call was in flight (499: client closed request).\n UNS_V2_TRANSPORT_ABORTED: { code: 'DATA_ABORTED', status: 499, message: 'The data call was aborted' },\n UNS_V2_PROTOCOL_ERROR: { code: 'DATA_BAD_RESPONSE', status: 502, message: 'UNS answered with an invalid response' },\n};\n\nfunction codeHint(code: string, details: Record<string, unknown>): string | undefined {\n if (code === 'APP_QUOTA_EXCEEDED') {\n const resource = typeof details.resource === 'string' ? details.resource : '';\n return QUOTA_HINTS[resource] ?? 'This App reached a collection/index quota. Remove unused collections or indexes through the tier0 MCP.';\n }\n return CODE_HINTS[code];\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** Translates a failed UNS call of the SDK client after `attempts` requests, sent with `idempotencyKey`. */\nexport function toDataError(error: UnsV2Error, attempts = 1, idempotencyKey?: string): DataError {\n const common = {\n upstreamStatus: error.status,\n requestId: error.requestId,\n execution: error.execution,\n retry: error.retry,\n attempts,\n idempotencyKey,\n cause: error,\n };\n const unknown = error.outcomeUnknown ? '; the write outcome is unknown' : '';\n // An ingress or load balancer answers 502/503/504 without the UNS envelope during\n // rolling releases and pod restarts, like any unavailable upstream. UNS v2 routes\n // answer every other error with the envelope (401/403/429 included), so other\n // unenveloped responses stay DATA_BAD_RESPONSE.\n if (error.code === 'UNS_V2_PROTOCOL_ERROR' && (error.status === 502 || error.status === 503 || error.status === 504)) {\n return new DataError({\n ...common,\n message: `The Tier0 data gateway answered ${error.operation} with HTTP ${error.status}${unknown}.`,\n status: 503,\n code: `HTTP_${error.status}`,\n });\n }\n const transport = TRANSPORT_FAILURES[error.code];\n if (transport) {\n return new DataError({ ...common, message: `${transport.message} (${error.operation})${unknown}.`, status: transport.status, code: transport.code });\n }\n\n const httpStatus = error.status ?? 0;\n const data = isObject(error.data) ? error.data : {};\n // Only `data.reason` is a code; `error.reason` repeats the message text.\n const reason = typeof data.reason === 'string' ? data.reason : undefined;\n const code = error.code;\n const msg = error.message;\n const hint = codeHint(code, data) ?? error.repair;\n let message = `${msg} (${code})`;\n if (reason === ACCESS_REASONS.permissionMissing) {\n message =\n data.missingPermission === 'uns.delete'\n ? `Deleting records requires the App key to hold uns.delete, and this App's key does not (${code}). ` +\n 'Model removal as a status change such as `archived`, or ask a workspace admin to grant uns.delete.'\n : `The App key lacks ${typeof data.missingPermission === 'string' ? data.missingPermission : 'a permission'} for this operation (${code}); ask a workspace admin.`;\n } else if (reason === ACCESS_REASONS.notGranted) {\n message = `${message} This App's grant does not cover the collection or operation; ask a workspace admin to restore the grant.`;\n } else if (reason === ACCESS_REASONS.notFound) {\n message = `${message} The collection was archived or deleted; the data layer ensures the declared collections again.`;\n } else if (httpStatus === 401) {\n message = `Tier0 rejected the App credential for ${error.operation} (${code}). The platform injects TIER0_API_KEY; do not replace it.`;\n } else if (hint) {\n message = `${message} ${hint}`;\n }\n\n return new DataError({ ...common, message, status: appStatus(httpStatus, code), code, reason, upstreamStatus: httpStatus, details: data });\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@tier0/sdk-v2/data` — server-only App data layer over Tier0 UNS collections.
|
|
3
|
+
*
|
|
4
|
+
* import { createDataClient, defineCollection } from '@tier0/sdk-v2/data';
|
|
5
|
+
*
|
|
6
|
+
* const data = createDataClient({ collections: [workOrders] });
|
|
7
|
+
* const open = await data.collection(workOrders).find({ status: 'OPEN' }, { limit: 50 }).toArray();
|
|
8
|
+
*
|
|
9
|
+
* Declarations are ensured in one batch on first access. Requires `zod` 4.
|
|
10
|
+
* Client code imports declarations and types from `@tier0/sdk-v2/data/define`.
|
|
11
|
+
*/
|
|
12
|
+
export { createDataClient } from './client.js';
|
|
13
|
+
export { MAX_BATCH_QUERIES } from './client.js';
|
|
14
|
+
export type { BatchQueries, BatchResults, DataClient, DataClientConfig, SettledBatchResults, TransactAction, TransactResult, TransactResultItem, TransactStep } from './client.js';
|
|
15
|
+
export type { DataEnvironment, EnsureConflict, EnsureNote, EnsureResult, EnsureState, EnsureWarning, Logger } from './bootstrap.js';
|
|
16
|
+
export { MAX_ATOMIC_ITEMS, MAX_GET_IDS } from './collection.js';
|
|
17
|
+
export type { BatchQuery, BulkOperation, CappedCount, Collection, CollectionQueries, Cursor, FoundPage, ValueCount, FindOneAndOptions, FindOptions, FindPageOptions, Projection, Update, UpdateOptions, WithMeta } from './collection.js';
|
|
18
|
+
export { currentDataSubject, runAsApp, runWithRequestContext } from './context.js';
|
|
19
|
+
export { redactRestricted, SUBSCRIBE_IDLE_TIMEOUT_MS } from './subscribe.js';
|
|
20
|
+
export type { ChangeEvent, CollectionChange, RecordChange, SubscribeOptions, SubscriptionEvent } from './subscribe.js';
|
|
21
|
+
export { ACCESS_REASONS, DataError } from './error.js';
|
|
22
|
+
export * from './declarations.js';
|
|
23
|
+
export { toSortPairs } from './sort.js';
|
|
24
|
+
export type { Filter, Sort, SortDirection, SortPairs } from './sort.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.toSortPairs = exports.DataError = exports.ACCESS_REASONS = exports.SUBSCRIBE_IDLE_TIMEOUT_MS = exports.redactRestricted = exports.runWithRequestContext = exports.runAsApp = exports.currentDataSubject = exports.MAX_GET_IDS = exports.MAX_ATOMIC_ITEMS = exports.MAX_BATCH_QUERIES = exports.createDataClient = void 0;
|
|
18
|
+
/**
|
|
19
|
+
* `@tier0/sdk-v2/data` — server-only App data layer over Tier0 UNS collections.
|
|
20
|
+
*
|
|
21
|
+
* import { createDataClient, defineCollection } from '@tier0/sdk-v2/data';
|
|
22
|
+
*
|
|
23
|
+
* const data = createDataClient({ collections: [workOrders] });
|
|
24
|
+
* const open = await data.collection(workOrders).find({ status: 'OPEN' }, { limit: 50 }).toArray();
|
|
25
|
+
*
|
|
26
|
+
* Declarations are ensured in one batch on first access. Requires `zod` 4.
|
|
27
|
+
* Client code imports declarations and types from `@tier0/sdk-v2/data/define`.
|
|
28
|
+
*/
|
|
29
|
+
var client_js_1 = require("./client.js");
|
|
30
|
+
Object.defineProperty(exports, "createDataClient", { enumerable: true, get: function () { return client_js_1.createDataClient; } });
|
|
31
|
+
var client_js_2 = require("./client.js");
|
|
32
|
+
Object.defineProperty(exports, "MAX_BATCH_QUERIES", { enumerable: true, get: function () { return client_js_2.MAX_BATCH_QUERIES; } });
|
|
33
|
+
var collection_js_1 = require("./collection.js");
|
|
34
|
+
Object.defineProperty(exports, "MAX_ATOMIC_ITEMS", { enumerable: true, get: function () { return collection_js_1.MAX_ATOMIC_ITEMS; } });
|
|
35
|
+
Object.defineProperty(exports, "MAX_GET_IDS", { enumerable: true, get: function () { return collection_js_1.MAX_GET_IDS; } });
|
|
36
|
+
var context_js_1 = require("./context.js");
|
|
37
|
+
Object.defineProperty(exports, "currentDataSubject", { enumerable: true, get: function () { return context_js_1.currentDataSubject; } });
|
|
38
|
+
Object.defineProperty(exports, "runAsApp", { enumerable: true, get: function () { return context_js_1.runAsApp; } });
|
|
39
|
+
Object.defineProperty(exports, "runWithRequestContext", { enumerable: true, get: function () { return context_js_1.runWithRequestContext; } });
|
|
40
|
+
var subscribe_js_1 = require("./subscribe.js");
|
|
41
|
+
Object.defineProperty(exports, "redactRestricted", { enumerable: true, get: function () { return subscribe_js_1.redactRestricted; } });
|
|
42
|
+
Object.defineProperty(exports, "SUBSCRIBE_IDLE_TIMEOUT_MS", { enumerable: true, get: function () { return subscribe_js_1.SUBSCRIBE_IDLE_TIMEOUT_MS; } });
|
|
43
|
+
var error_js_1 = require("./error.js");
|
|
44
|
+
Object.defineProperty(exports, "ACCESS_REASONS", { enumerable: true, get: function () { return error_js_1.ACCESS_REASONS; } });
|
|
45
|
+
Object.defineProperty(exports, "DataError", { enumerable: true, get: function () { return error_js_1.DataError; } });
|
|
46
|
+
__exportStar(require("./declarations.js"), exports);
|
|
47
|
+
var sort_js_1 = require("./sort.js");
|
|
48
|
+
Object.defineProperty(exports, "toSortPairs", { enumerable: true, get: function () { return sort_js_1.toSortPairs; } });
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;GAUG;AACH,yCAA+C;AAAtC,6GAAA,gBAAgB,OAAA;AACzB,yCAAgD;AAAvC,8GAAA,iBAAiB,OAAA;AAG1B,iDAAgE;AAAvD,iHAAA,gBAAgB,OAAA;AAAE,4GAAA,WAAW,OAAA;AAEtC,2CAAmF;AAA1E,gHAAA,kBAAkB,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AAC5D,+CAA6E;AAApE,gHAAA,gBAAgB,OAAA;AAAE,yHAAA,yBAAyB,OAAA;AAEpD,uCAAuD;AAA9C,0GAAA,cAAc,OAAA;AAAE,qGAAA,SAAS,OAAA;AAClC,oDAAkC;AAClC,qCAAwC;AAA/B,sGAAA,WAAW,OAAA","sourcesContent":["/**\n * `@tier0/sdk-v2/data` — server-only App data layer over Tier0 UNS collections.\n *\n * import { createDataClient, defineCollection } from '@tier0/sdk-v2/data';\n *\n * const data = createDataClient({ collections: [workOrders] });\n * const open = await data.collection(workOrders).find({ status: 'OPEN' }, { limit: 50 }).toArray();\n *\n * Declarations are ensured in one batch on first access. Requires `zod` 4.\n * Client code imports declarations and types from `@tier0/sdk-v2/data/define`.\n */\nexport { createDataClient } from './client.js';\nexport { MAX_BATCH_QUERIES } from './client.js';\nexport type { BatchQueries, BatchResults, DataClient, DataClientConfig, SettledBatchResults, TransactAction, TransactResult, TransactResultItem, TransactStep } from './client.js';\nexport type { DataEnvironment, EnsureConflict, EnsureNote, EnsureResult, EnsureState, EnsureWarning, Logger } from './bootstrap.js';\nexport { MAX_ATOMIC_ITEMS, MAX_GET_IDS } from './collection.js';\nexport type { BatchQuery, BulkOperation, CappedCount, Collection, CollectionQueries, Cursor, FoundPage, ValueCount, FindOneAndOptions, FindOptions, FindPageOptions, Projection, Update, UpdateOptions, WithMeta } from './collection.js';\nexport { currentDataSubject, runAsApp, runWithRequestContext } from './context.js';\nexport { redactRestricted, SUBSCRIBE_IDLE_TIMEOUT_MS } from './subscribe.js';\nexport type { ChangeEvent, CollectionChange, RecordChange, SubscribeOptions, SubscriptionEvent } from './subscribe.js';\nexport { ACCESS_REASONS, DataError } from './error.js';\nexport * from './declarations.js';\nexport { toSortPairs } from './sort.js';\nexport type { Filter, Sort, SortDirection, SortPairs } from './sort.js';\n"]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod 4 → UNS record schema normalizer, plus write-time validation.
|
|
3
|
+
*
|
|
4
|
+
* UNS stores one closed JSON-schema subset per collection: `type`,
|
|
5
|
+
* `properties`, `required`, `additionalProperties: false`, `items`, `enum`,
|
|
6
|
+
* `minimum`, `maximum`, declared `format`, `title`, `description`. `toRecordSchema` converts the
|
|
7
|
+
* `z.toJSONSchema` output into exactly that subset and rejects every other
|
|
8
|
+
* keyword with a concrete replacement, so a declaration that cannot be stored
|
|
9
|
+
* fails when it is compiled (an App can compile its declarations at build
|
|
10
|
+
* time) instead of on the first request.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { type CollectionDefinition } from './define.js';
|
|
14
|
+
export type RecordSchemaType = 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean';
|
|
15
|
+
export type EnumValue = string | number | boolean;
|
|
16
|
+
export interface RecordSchema {
|
|
17
|
+
type: RecordSchemaType;
|
|
18
|
+
/** Display annotation; does not add range/date checks or convert stored values. */
|
|
19
|
+
format?: 'int32' | 'float' | 'double' | 'date-time';
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
properties?: Record<string, RecordSchema>;
|
|
23
|
+
required?: string[];
|
|
24
|
+
additionalProperties?: false;
|
|
25
|
+
items?: RecordSchema;
|
|
26
|
+
enum?: EnumValue[];
|
|
27
|
+
minimum?: number;
|
|
28
|
+
maximum?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface NormalizedIndex {
|
|
31
|
+
path?: string;
|
|
32
|
+
paths?: string[];
|
|
33
|
+
unique?: true;
|
|
34
|
+
kind?: 'gin';
|
|
35
|
+
expireAfterSeconds?: number;
|
|
36
|
+
}
|
|
37
|
+
/** One ensure item, exactly as it is sent to `/uns/app/collections/ensure`. */
|
|
38
|
+
export interface CompiledCollection {
|
|
39
|
+
alias: string;
|
|
40
|
+
recordSchema: RecordSchema;
|
|
41
|
+
indexes: NormalizedIndex[];
|
|
42
|
+
description?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SchemaIssue {
|
|
45
|
+
path: string;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class CollectionSchemaError extends Error {
|
|
49
|
+
readonly alias: string;
|
|
50
|
+
readonly issues: SchemaIssue[];
|
|
51
|
+
constructor(alias: string, issues: SchemaIssue[]);
|
|
52
|
+
}
|
|
53
|
+
/** UNS limits (unsmeta Schema.validate and collection indexes); title/description are UTF-8 bytes. */
|
|
54
|
+
export declare const SCHEMA_LIMITS: {
|
|
55
|
+
readonly depth: 8;
|
|
56
|
+
readonly properties: 128;
|
|
57
|
+
readonly enumValues: 100;
|
|
58
|
+
readonly title: 512;
|
|
59
|
+
readonly description: 2048;
|
|
60
|
+
readonly indexes: 16;
|
|
61
|
+
readonly indexPaths: 3;
|
|
62
|
+
readonly ttlIndexes: 1;
|
|
63
|
+
readonly minExpireAfterSeconds: 60;
|
|
64
|
+
readonly maxExpireAfterSeconds: 31536000;
|
|
65
|
+
};
|
|
66
|
+
type JsonNode = Record<string, unknown>;
|
|
67
|
+
/** Raw `z.toJSONSchema` output; exported for the snapshot tests. */
|
|
68
|
+
export declare function zodJsonSchema(schema: z.ZodType): JsonNode;
|
|
69
|
+
/** Converts a Zod object schema to the UNS record-schema subset or throws `CollectionSchemaError`. */
|
|
70
|
+
export declare function toRecordSchema(alias: string, schema: z.ZodType): RecordSchema;
|
|
71
|
+
/** Resolves a dotted business path in a record schema; array levels accept index segments. */
|
|
72
|
+
export declare function recordSchemaAt(schema: RecordSchema, path: string): RecordSchema | undefined;
|
|
73
|
+
/** Ensure payload for one declaration; memoized per definition object. */
|
|
74
|
+
export declare function compileCollection(definition: CollectionDefinition): CompiledCollection;
|
|
75
|
+
/** Splits `_id` / `_meta` off a document and strictly validates the body. */
|
|
76
|
+
export declare function validateDocument(definition: CollectionDefinition, document: Record<string, unknown>): {
|
|
77
|
+
id?: string;
|
|
78
|
+
data: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Validates `data` of a transaction step. Fields filled by `bindings`
|
|
82
|
+
* (`data.<field>...`) are checked only for being declared; every literal
|
|
83
|
+
* field is strictly validated, and other required fields must be present.
|
|
84
|
+
*/
|
|
85
|
+
export declare function validateStepData(definition: CollectionDefinition, data: Record<string, unknown>, boundFields: readonly string[]): Record<string, unknown>;
|
|
86
|
+
/** Validates update-operator documents against the declaration (paths and values). */
|
|
87
|
+
export declare function validateUpdate(definition: CollectionDefinition, update: Record<string, unknown>): Record<string, unknown>;
|
|
88
|
+
export {};
|