@opensaas/stack-core 0.44.0-alpha.5 → 0.44.0-alpha.7
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/CHANGELOG.md +1051 -0
- package/dist/.build-hash +1 -1
- package/dist/access/actor.d.ts +56 -0
- package/dist/access/actor.d.ts.map +1 -0
- package/dist/access/actor.js +66 -0
- package/dist/access/actor.js.map +1 -0
- package/dist/access/decide-advertisement.d.ts +55 -0
- package/dist/access/decide-advertisement.d.ts.map +1 -0
- package/dist/access/decide-advertisement.js +125 -0
- package/dist/access/decide-advertisement.js.map +1 -0
- package/dist/access/declared-dependencies.d.ts +4 -89
- package/dist/access/declared-dependencies.d.ts.map +1 -1
- package/dist/access/declared-dependencies.js +14 -84
- package/dist/access/declared-dependencies.js.map +1 -1
- package/dist/access/depth-limits.d.ts +2 -0
- package/dist/access/depth-limits.d.ts.map +1 -1
- package/dist/access/depth-limits.js +2 -0
- package/dist/access/depth-limits.js.map +1 -1
- package/dist/access/engine.d.ts +1 -24
- package/dist/access/engine.d.ts.map +1 -1
- package/dist/access/engine.js +0 -35
- package/dist/access/engine.js.map +1 -1
- package/dist/access/field-access.d.ts +43 -19
- package/dist/access/field-access.d.ts.map +1 -1
- package/dist/access/field-access.js +206 -185
- package/dist/access/field-access.js.map +1 -1
- package/dist/access/index.d.ts +5 -6
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +6 -7
- package/dist/access/index.js.map +1 -1
- package/dist/access/rule-item.d.ts +42 -0
- package/dist/access/rule-item.d.ts.map +1 -0
- package/dist/access/rule-item.js +215 -0
- package/dist/access/rule-item.js.map +1 -0
- package/dist/access/session-vocabulary.d.ts +124 -0
- package/dist/access/session-vocabulary.d.ts.map +1 -0
- package/dist/access/session-vocabulary.js +366 -0
- package/dist/access/session-vocabulary.js.map +1 -0
- package/dist/access/transaction-registry.d.ts +6 -0
- package/dist/access/transaction-registry.d.ts.map +1 -1
- package/dist/access/transaction-registry.js +19 -2
- package/dist/access/transaction-registry.js.map +1 -1
- package/dist/access/types.d.ts +66 -0
- package/dist/access/types.d.ts.map +1 -1
- package/dist/access/vocabulary-filter-specs.d.ts +17 -0
- package/dist/access/vocabulary-filter-specs.d.ts.map +1 -0
- package/dist/access/vocabulary-filter-specs.js +27 -0
- package/dist/access/vocabulary-filter-specs.js.map +1 -0
- package/dist/client-safe.d.ts +8 -0
- package/dist/client-safe.d.ts.map +1 -0
- package/dist/client-safe.js +8 -0
- package/dist/client-safe.js.map +1 -0
- package/dist/config/field-kind.d.ts +7 -21
- package/dist/config/field-kind.d.ts.map +1 -1
- package/dist/config/field-kind.js +8 -5
- package/dist/config/field-kind.js.map +1 -1
- package/dist/config/has-access-gate.d.ts +20 -0
- package/dist/config/has-access-gate.d.ts.map +1 -0
- package/dist/config/has-access-gate.js +26 -0
- package/dist/config/has-access-gate.js.map +1 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/list-view-keys.d.ts +5 -0
- package/dist/config/list-view-keys.d.ts.map +1 -0
- package/dist/config/list-view-keys.js +18 -0
- package/dist/config/list-view-keys.js.map +1 -0
- package/dist/config/mcp-default-tools.d.ts +3 -0
- package/dist/config/mcp-default-tools.d.ts.map +1 -0
- package/dist/config/mcp-default-tools.js +14 -0
- package/dist/config/mcp-default-tools.js.map +1 -0
- package/dist/config/mcp-tool-names.d.ts +2 -0
- package/dist/config/mcp-tool-names.d.ts.map +1 -1
- package/dist/config/mcp-tool-names.js +17 -5
- package/dist/config/mcp-tool-names.js.map +1 -1
- package/dist/config/nav-count.d.ts +8 -16
- package/dist/config/nav-count.d.ts.map +1 -1
- package/dist/config/nav-count.js +20 -32
- package/dist/config/nav-count.js.map +1 -1
- package/dist/config/plugin-engine.d.ts.map +1 -1
- package/dist/config/plugin-engine.js +6 -0
- package/dist/config/plugin-engine.js.map +1 -1
- package/dist/config/preset-views.d.ts +22 -0
- package/dist/config/preset-views.d.ts.map +1 -0
- package/dist/config/preset-views.js +46 -0
- package/dist/config/preset-views.js.map +1 -0
- package/dist/config/row-action-availability.d.ts +4 -0
- package/dist/config/row-action-availability.d.ts.map +1 -0
- package/dist/config/row-action-availability.js +20 -0
- package/dist/config/row-action-availability.js.map +1 -0
- package/dist/config/types.d.ts +409 -34
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/engine-context.d.ts +2 -0
- package/dist/context/engine-context.d.ts.map +1 -1
- package/dist/context/engine-context.js +8 -0
- package/dist/context/engine-context.js.map +1 -1
- package/dist/context/hook-pipeline.d.ts +6 -1
- package/dist/context/hook-pipeline.d.ts.map +1 -1
- package/dist/context/hook-pipeline.js +6 -4
- package/dist/context/hook-pipeline.js.map +1 -1
- package/dist/context/index.d.ts +10 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +217 -94
- package/dist/context/index.js.map +1 -1
- package/dist/context/junction.d.ts +28 -21
- package/dist/context/junction.d.ts.map +1 -1
- package/dist/context/junction.js +74 -69
- package/dist/context/junction.js.map +1 -1
- package/dist/context/plugin-field-write.d.ts.map +1 -1
- package/dist/context/plugin-field-write.js +19 -25
- package/dist/context/plugin-field-write.js.map +1 -1
- package/dist/context/process-lifetime.d.ts +8 -0
- package/dist/context/process-lifetime.d.ts.map +1 -0
- package/dist/context/process-lifetime.js +14 -0
- package/dist/context/process-lifetime.js.map +1 -0
- package/dist/context/relationship-input.d.ts +2 -15
- package/dist/context/relationship-input.d.ts.map +1 -1
- package/dist/context/relationship-input.js +44 -85
- package/dist/context/relationship-input.js.map +1 -1
- package/dist/context/transaction-boundary.d.ts +3 -2
- package/dist/context/transaction-boundary.d.ts.map +1 -1
- package/dist/context/transaction-boundary.js +17 -2
- package/dist/context/transaction-boundary.js.map +1 -1
- package/dist/context/write-pipeline.d.ts +5 -19
- package/dist/context/write-pipeline.d.ts.map +1 -1
- package/dist/context/write-pipeline.js +54 -92
- package/dist/context/write-pipeline.js.map +1 -1
- package/dist/context/write-target.d.ts +52 -0
- package/dist/context/write-target.d.ts.map +1 -0
- package/dist/context/write-target.js +118 -0
- package/dist/context/write-target.js.map +1 -0
- package/dist/contract/dependencies.d.ts +24 -10
- package/dist/contract/dependencies.d.ts.map +1 -1
- package/dist/contract/dependencies.js +120 -80
- package/dist/contract/dependencies.js.map +1 -1
- package/dist/contract/derive.d.ts +6 -11
- package/dist/contract/derive.d.ts.map +1 -1
- package/dist/contract/derive.js +256 -211
- package/dist/contract/derive.js.map +1 -1
- package/dist/contract/fixtures/contract-configs.d.ts +5 -0
- package/dist/contract/fixtures/contract-configs.d.ts.map +1 -1
- package/dist/contract/fixtures/contract-configs.js +21 -0
- package/dist/contract/fixtures/contract-configs.js.map +1 -1
- package/dist/contract/id-boundary.js +1 -1
- package/dist/contract/id-boundary.js.map +1 -1
- package/dist/contract/prisma.js +2 -2
- package/dist/contract/prisma.js.map +1 -1
- package/dist/contract/strategy.d.ts +13 -0
- package/dist/contract/strategy.d.ts.map +1 -0
- package/dist/contract/strategy.js +38 -0
- package/dist/contract/strategy.js.map +1 -0
- package/dist/db/client-alias.d.ts +12 -0
- package/dist/db/client-alias.d.ts.map +1 -0
- package/dist/db/client-alias.js +8 -0
- package/dist/db/client-alias.js.map +1 -0
- package/dist/extend.d.ts +2 -2
- package/dist/extend.d.ts.map +1 -1
- package/dist/extend.js.map +1 -1
- package/dist/fields/index.d.ts +12 -14
- package/dist/fields/index.d.ts.map +1 -1
- package/dist/fields/index.js +217 -67
- package/dist/fields/index.js.map +1 -1
- package/dist/filter/collect.d.ts +43 -25
- package/dist/filter/collect.d.ts.map +1 -1
- package/dist/filter/collect.js +107 -38
- package/dist/filter/collect.js.map +1 -1
- package/dist/filter/index.d.ts +7 -5
- package/dist/filter/index.d.ts.map +1 -1
- package/dist/filter/index.js +6 -14
- package/dist/filter/index.js.map +1 -1
- package/dist/filter/map.d.ts +112 -20
- package/dist/filter/map.d.ts.map +1 -1
- package/dist/filter/map.js +271 -52
- package/dist/filter/map.js.map +1 -1
- package/dist/filter/parse.d.ts +70 -26
- package/dist/filter/parse.d.ts.map +1 -1
- package/dist/filter/parse.js +212 -79
- package/dist/filter/parse.js.map +1 -1
- package/dist/filter/record-id.d.ts +19 -0
- package/dist/filter/record-id.d.ts.map +1 -0
- package/dist/filter/record-id.js +37 -0
- package/dist/filter/record-id.js.map +1 -0
- package/dist/filter/serialize.d.ts +45 -19
- package/dist/filter/serialize.d.ts.map +1 -1
- package/dist/filter/serialize.js +146 -50
- package/dist/filter/serialize.js.map +1 -1
- package/dist/filter/types.d.ts +132 -21
- package/dist/filter/types.d.ts.map +1 -1
- package/dist/filter/types.js +2 -11
- package/dist/filter/types.js.map +1 -1
- package/dist/hooks/index.d.ts +6 -3
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +38 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +11 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +8 -8
- package/dist/internal.js.map +1 -1
- package/dist/lib/database-errors.d.ts +2 -1
- package/dist/lib/database-errors.d.ts.map +1 -1
- package/dist/lib/database-errors.js +5 -4
- package/dist/lib/database-errors.js.map +1 -1
- package/dist/mcp/advertise.d.ts +5 -13
- package/dist/mcp/advertise.d.ts.map +1 -1
- package/dist/mcp/advertise.js +7 -22
- package/dist/mcp/advertise.js.map +1 -1
- package/dist/mcp/arguments.d.ts.map +1 -1
- package/dist/mcp/arguments.js +8 -11
- package/dist/mcp/arguments.js.map +1 -1
- package/dist/mcp/field-schema.d.ts +4 -15
- package/dist/mcp/field-schema.d.ts.map +1 -1
- package/dist/mcp/field-schema.js +50 -69
- package/dist/mcp/field-schema.js.map +1 -1
- package/dist/mcp/handler.d.ts +111 -18
- package/dist/mcp/handler.d.ts.map +1 -1
- package/dist/mcp/handler.js +231 -87
- package/dist/mcp/handler.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/procedure-tools.d.ts +63 -0
- package/dist/mcp/procedure-tools.d.ts.map +1 -0
- package/dist/mcp/procedure-tools.js +139 -0
- package/dist/mcp/procedure-tools.js.map +1 -0
- package/dist/mcp/projection.d.ts +6 -5
- package/dist/mcp/projection.d.ts.map +1 -1
- package/dist/mcp/projection.js +33 -38
- package/dist/mcp/projection.js.map +1 -1
- package/dist/mcp/reachability.d.ts +13 -0
- package/dist/mcp/reachability.d.ts.map +1 -0
- package/dist/mcp/reachability.js +51 -0
- package/dist/mcp/reachability.js.map +1 -0
- package/dist/mcp/relation-member.d.ts +15 -0
- package/dist/mcp/relation-member.d.ts.map +1 -0
- package/dist/mcp/relation-member.js +50 -0
- package/dist/mcp/relation-member.js.map +1 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.d.ts.map +1 -1
- package/dist/mcp/where-id-boundary.js +12 -24
- package/dist/mcp/where-id-boundary.js.map +1 -1
- package/dist/mcp/where-reachability.d.ts +10 -0
- package/dist/mcp/where-reachability.d.ts.map +1 -0
- package/dist/mcp/where-reachability.js +88 -0
- package/dist/mcp/where-reachability.js.map +1 -0
- package/dist/members/claims.d.ts +71 -0
- package/dist/members/claims.d.ts.map +1 -0
- package/dist/members/claims.js +199 -0
- package/dist/members/claims.js.map +1 -0
- package/dist/members/list-members.d.ts +87 -0
- package/dist/members/list-members.d.ts.map +1 -0
- package/dist/members/list-members.js +250 -0
- package/dist/members/list-members.js.map +1 -0
- package/dist/procedures/client.d.ts +163 -0
- package/dist/procedures/client.d.ts.map +1 -0
- package/dist/procedures/client.js +152 -0
- package/dist/procedures/client.js.map +1 -0
- package/dist/procedures/codes.d.ts +23 -0
- package/dist/procedures/codes.d.ts.map +1 -0
- package/dist/procedures/codes.js +46 -0
- package/dist/procedures/codes.js.map +1 -0
- package/dist/procedures/context-face.d.ts +4 -0
- package/dist/procedures/context-face.d.ts.map +1 -0
- package/dist/procedures/context-face.js +31 -0
- package/dist/procedures/context-face.js.map +1 -0
- package/dist/procedures/failures.d.ts +31 -0
- package/dist/procedures/failures.d.ts.map +1 -0
- package/dist/procedures/failures.js +51 -0
- package/dist/procedures/failures.js.map +1 -0
- package/dist/procedures/http.d.ts +114 -0
- package/dist/procedures/http.d.ts.map +1 -0
- package/dist/procedures/http.js +224 -0
- package/dist/procedures/http.js.map +1 -0
- package/dist/procedures/index.d.ts +7 -0
- package/dist/procedures/index.d.ts.map +1 -0
- package/dist/procedures/index.js +11 -0
- package/dist/procedures/index.js.map +1 -0
- package/dist/procedures/procedure.d.ts +204 -0
- package/dist/procedures/procedure.d.ts.map +1 -0
- package/dist/procedures/procedure.js +123 -0
- package/dist/procedures/procedure.js.map +1 -0
- package/dist/procedures/result.d.ts +42 -0
- package/dist/procedures/result.d.ts.map +1 -0
- package/dist/procedures/result.js +51 -0
- package/dist/procedures/result.js.map +1 -0
- package/dist/procedures/run.d.ts +36 -0
- package/dist/procedures/run.d.ts.map +1 -0
- package/dist/procedures/run.js +76 -0
- package/dist/procedures/run.js.map +1 -0
- package/dist/procedures/server.d.ts +131 -0
- package/dist/procedures/server.d.ts.map +1 -0
- package/dist/procedures/server.js +115 -0
- package/dist/procedures/server.js.map +1 -0
- package/dist/procedures/validate.d.ts +60 -0
- package/dist/procedures/validate.d.ts.map +1 -0
- package/dist/procedures/validate.js +254 -0
- package/dist/procedures/validate.js.map +1 -0
- package/dist/procedures/web-session.d.ts +12 -0
- package/dist/procedures/web-session.d.ts.map +1 -0
- package/dist/procedures/web-session.js +35 -0
- package/dist/procedures/web-session.js.map +1 -0
- package/dist/query/relationship-options.d.ts +8 -0
- package/dist/query/relationship-options.d.ts.map +1 -1
- package/dist/query/relationship-options.js +18 -4
- package/dist/query/relationship-options.js.map +1 -1
- package/dist/secured/binding.d.ts +84 -0
- package/dist/secured/binding.d.ts.map +1 -0
- package/dist/secured/binding.js +52 -0
- package/dist/secured/binding.js.map +1 -0
- package/dist/secured/declared-branch.d.ts +11 -0
- package/dist/secured/declared-branch.d.ts.map +1 -0
- package/dist/secured/declared-branch.js +17 -0
- package/dist/secured/declared-branch.js.map +1 -0
- package/dist/secured/field-visibility.d.ts +56 -0
- package/dist/secured/field-visibility.d.ts.map +1 -0
- package/dist/secured/field-visibility.js +624 -0
- package/dist/secured/field-visibility.js.map +1 -0
- package/dist/secured/include.d.ts +77 -37
- package/dist/secured/include.d.ts.map +1 -1
- package/dist/secured/include.js +228 -122
- package/dist/secured/include.js.map +1 -1
- package/dist/secured/lock.d.ts +8 -2
- package/dist/secured/lock.d.ts.map +1 -1
- package/dist/secured/lock.js +44 -15
- package/dist/secured/lock.js.map +1 -1
- package/dist/secured/lower.d.ts.map +1 -1
- package/dist/secured/lower.js +15 -4
- package/dist/secured/lower.js.map +1 -1
- package/dist/secured/read.d.ts +13 -52
- package/dist/secured/read.d.ts.map +1 -1
- package/dist/secured/read.js +88 -614
- package/dist/secured/read.js.map +1 -1
- package/dist/secured/select.d.ts +0 -24
- package/dist/secured/select.d.ts.map +1 -1
- package/dist/secured/select.js +60 -153
- package/dist/secured/select.js.map +1 -1
- package/dist/secured/vocabulary.d.ts +13 -1
- package/dist/secured/vocabulary.d.ts.map +1 -1
- package/dist/secured/vocabulary.js +173 -83
- package/dist/secured/vocabulary.js.map +1 -1
- package/dist/testing/untyped-rule.d.ts +8 -0
- package/dist/testing/untyped-rule.d.ts.map +1 -0
- package/dist/testing/untyped-rule.js +4 -0
- package/dist/testing/untyped-rule.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/rows.d.ts +18 -1
- package/dist/types/rows.d.ts.map +1 -1
- package/dist/validation/config-refusal.d.ts +3 -1
- package/dist/validation/config-refusal.d.ts.map +1 -1
- package/dist/validation/database-config.d.ts +1 -15
- package/dist/validation/database-config.d.ts.map +1 -1
- package/dist/validation/database-config.js +32 -1
- package/dist/validation/database-config.js.map +1 -1
- package/dist/validation/default-value.d.ts.map +1 -1
- package/dist/validation/default-value.js +3 -8
- package/dist/validation/default-value.js.map +1 -1
- package/dist/validation/extension-packs.d.ts.map +1 -1
- package/dist/validation/extension-packs.js +1 -0
- package/dist/validation/extension-packs.js.map +1 -1
- package/dist/validation/field-config.d.ts +3 -2
- package/dist/validation/field-config.d.ts.map +1 -1
- package/dist/validation/field-config.js +3 -1
- package/dist/validation/field-config.js.map +1 -1
- package/dist/validation/field-names.d.ts +2 -1
- package/dist/validation/field-names.d.ts.map +1 -1
- package/dist/validation/field-names.js +76 -63
- package/dist/validation/field-names.js.map +1 -1
- package/dist/validation/identifier-names.d.ts +1 -0
- package/dist/validation/identifier-names.d.ts.map +1 -1
- package/dist/validation/identifier-names.js +17 -9
- package/dist/validation/identifier-names.js.map +1 -1
- package/dist/validation/needs-closure.d.ts +30 -14
- package/dist/validation/needs-closure.d.ts.map +1 -1
- package/dist/validation/needs-closure.js +184 -31
- package/dist/validation/needs-closure.js.map +1 -1
- package/dist/validation/relations.d.ts.map +1 -1
- package/dist/validation/relations.js +11 -0
- package/dist/validation/relations.js.map +1 -1
- package/dist/validation/schema.d.ts +4 -3
- package/dist/validation/schema.d.ts.map +1 -1
- package/dist/validation/schema.js +8 -6
- package/dist/validation/schema.js.map +1 -1
- package/package.json +26 -10
- package/dist/access/field-visibility.d.ts +0 -58
- package/dist/access/field-visibility.d.ts.map +0 -1
- package/dist/access/field-visibility.js +0 -383
- package/dist/access/field-visibility.js.map +0 -1
- package/dist/access/query-validation.d.ts +0 -30
- package/dist/access/query-validation.d.ts.map +0 -1
- package/dist/access/query-validation.js +0 -49
- package/dist/access/query-validation.js.map +0 -1
- package/dist/access/system-fields.d.ts +0 -2
- package/dist/access/system-fields.d.ts.map +0 -1
- package/dist/access/system-fields.js +0 -7
- package/dist/access/system-fields.js.map +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// @opensaas/stack-core/procedures/client
|
|
2
|
+
//
|
|
3
|
+
// The browser client for procedures, importable from a `'use client'` module.
|
|
4
|
+
// Its only runtime import is `codes.ts`, which imports nothing. See ADR-0086.
|
|
5
|
+
import { DECLARED_FAILURE_CODE_PATTERN, FAILURE_STATUS, isRefusalStatus, isReservedFailureCode, PROCEDURE_NAME_PATTERN, } from './codes.js';
|
|
6
|
+
const DEFAULT_BASE_URL = '/api/procedures';
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function isFieldErrors(value) {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return true;
|
|
13
|
+
return isRecord(value) && Object.values(value).every((message) => typeof message === 'string');
|
|
14
|
+
}
|
|
15
|
+
/** A success needs no `data` key: an output accepting `undefined` serialises without it. */
|
|
16
|
+
function isSuccess(status, body) {
|
|
17
|
+
return status === 200 && isRecord(body) && body.success === true;
|
|
18
|
+
}
|
|
19
|
+
function isFailure(status, body) {
|
|
20
|
+
if (!isRecord(body) || body.success !== false)
|
|
21
|
+
return false;
|
|
22
|
+
const { error } = body;
|
|
23
|
+
if (!isRecord(error) || typeof error.code !== 'string' || typeof error.message !== 'string') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (!isFieldErrors(error.fieldErrors))
|
|
27
|
+
return false;
|
|
28
|
+
if (isReservedFailureCode(error.code))
|
|
29
|
+
return status === FAILURE_STATUS[error.code];
|
|
30
|
+
return status === 200 && DECLARED_FAILURE_CODE_PATTERN.test(error.code);
|
|
31
|
+
}
|
|
32
|
+
function isRefusal(status, body) {
|
|
33
|
+
return isRefusalStatus(status) && isRecord(body) && typeof body.error === 'string';
|
|
34
|
+
}
|
|
35
|
+
function transport(reason, message, status) {
|
|
36
|
+
const error = { code: 'transport', reason, message };
|
|
37
|
+
if (status !== undefined)
|
|
38
|
+
error.status = status;
|
|
39
|
+
return { success: false, error };
|
|
40
|
+
}
|
|
41
|
+
function messageOf(error, fallback) {
|
|
42
|
+
return error instanceof Error && error.message !== '' ? error.message : fallback;
|
|
43
|
+
}
|
|
44
|
+
async function exchange(send, baseUrl, name, credentials, input) {
|
|
45
|
+
if (!PROCEDURE_NAME_PATTERN.test(name)) {
|
|
46
|
+
return transport('unsent', `${JSON.stringify(name)} is not a procedure name`);
|
|
47
|
+
}
|
|
48
|
+
let body;
|
|
49
|
+
try {
|
|
50
|
+
body = input === undefined ? undefined : JSON.stringify(input);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return transport('unsent', messageOf(error, 'The input cannot be serialised as JSON'));
|
|
54
|
+
}
|
|
55
|
+
let response;
|
|
56
|
+
try {
|
|
57
|
+
response = await send(new Request(`${baseUrl}/${name}`, {
|
|
58
|
+
method: 'POST',
|
|
59
|
+
headers: { 'content-type': 'application/json' },
|
|
60
|
+
credentials,
|
|
61
|
+
body,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return transport('network', messageOf(error, 'The request was not answered'));
|
|
66
|
+
}
|
|
67
|
+
const { status } = response;
|
|
68
|
+
let text;
|
|
69
|
+
try {
|
|
70
|
+
text = await response.text();
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return transport('network', messageOf(error, 'The response could not be read'), status);
|
|
74
|
+
}
|
|
75
|
+
let answer;
|
|
76
|
+
try {
|
|
77
|
+
answer = JSON.parse(text);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return transport('malformed', 'The response is not JSON', status);
|
|
81
|
+
}
|
|
82
|
+
if (isSuccess(status, answer))
|
|
83
|
+
return { success: true, data: answer.data };
|
|
84
|
+
if (isFailure(status, answer))
|
|
85
|
+
return { success: false, error: answer.error };
|
|
86
|
+
if (isRefusal(status, answer))
|
|
87
|
+
return transport('refused', answer.error, status);
|
|
88
|
+
return transport('malformed', 'The response is not a procedure result', status);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A typed client for an application's procedures, for browser code. Give it
|
|
92
|
+
* the **type** of the registry: the import is erased, so the registry, its
|
|
93
|
+
* schemas and everything `run` reaches stay on the server.
|
|
94
|
+
*
|
|
95
|
+
* A call POSTs JSON to the HTTP host and resolves, without throwing, to one of
|
|
96
|
+
* three outcomes: `{ success: true, data }`, a failure from the pipeline
|
|
97
|
+
* (`error.code` a reserved code or one the procedure declares), or a
|
|
98
|
+
* {@link ProcedureTransportFailure} (`error.code` `'transport'`) when the
|
|
99
|
+
* request was not sent or not answered, the host refused it before the
|
|
100
|
+
* pipeline ran, or the answer is not the host's. The status and the shape are
|
|
101
|
+
* checked together: an answer is read as a result only when it has the
|
|
102
|
+
* result's shape under the status the host gives that result, and a refusal
|
|
103
|
+
* only under one of the host's own refusal statuses (404, 405, 413, 415).
|
|
104
|
+
*
|
|
105
|
+
* The platform `fetch` follows redirects: a 307 or 308 sends the `POST` again
|
|
106
|
+
* to the new location, while a 301, 302 or 303 turns it into a `GET`, which
|
|
107
|
+
* the host answers as a `'refused'` 405.
|
|
108
|
+
*
|
|
109
|
+
* Identity is the session cookie alone. The client sends no `Authorization`
|
|
110
|
+
* header, which the host refuses, and takes no session argument. It sends the
|
|
111
|
+
* input exactly as given: no input is an empty body, which the host reads as
|
|
112
|
+
* `undefined`, so a procedure whose schema requires an object is called with
|
|
113
|
+
* `{}`.
|
|
114
|
+
*
|
|
115
|
+
* The client never retries, `RETRY` included: that code says the transaction
|
|
116
|
+
* rolled back, not that work outside it was undone, and after a `'network'`
|
|
117
|
+
* failure the call may have run. Whether running it again is safe is the
|
|
118
|
+
* caller's decision.
|
|
119
|
+
*
|
|
120
|
+
* The data is typed from the output schema and is not parsed again in the
|
|
121
|
+
* browser; the host has already parsed it. A procedure not exposed to `'web'`
|
|
122
|
+
* is callable in the type and answers as a `'refused'` 404.
|
|
123
|
+
*
|
|
124
|
+
* @typeParam TRegistry - `typeof` the registry object. Declare the registry
|
|
125
|
+
* with `satisfies ProcedureRegistry<Context>` rather than annotating it, so
|
|
126
|
+
* each name keeps its own procedure type. A registry type whose names are
|
|
127
|
+
* any string, an annotated one or none given, leaves no name callable.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* 'use client'
|
|
132
|
+
*
|
|
133
|
+
* import { createProcedureClient } from '@opensaas/stack-core/procedures/client'
|
|
134
|
+
* import type { procedures } from '@/lib/procedures'
|
|
135
|
+
*
|
|
136
|
+
* const call = createProcedureClient<typeof procedures>()
|
|
137
|
+
*
|
|
138
|
+
* export async function createPost(title: string): Promise<string> {
|
|
139
|
+
* const result = await call('createPost', { title })
|
|
140
|
+
* if (result.success) return result.data.id
|
|
141
|
+
* if (result.error.code === 'transport') throw new Error('Could not reach the server')
|
|
142
|
+
* throw new Error(result.error.message)
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export function createProcedureClient(options = {}) {
|
|
147
|
+
const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
148
|
+
const credentials = options.credentials ?? 'same-origin';
|
|
149
|
+
const send = options.fetch ?? ((request) => globalThis.fetch(request));
|
|
150
|
+
return (name, ...args) => exchange(send, baseUrl, name, credentials, args[0]);
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/procedures/client.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAG9E,OAAO,EACL,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAA;AAsInB,MAAM,gBAAgB,GAAG,iBAAiB,CAAA;AAE1C,SAA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SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAChF,OAAO,SAAS,CAAC,WAAW,EAAE,wCAAwC,EAAE,MAAM,CAAC,CAAA;AACjF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAAO,GAA2B,EAAE;IAEpC,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACzE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,aAAa,CAAA;IACxD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;IAE/E,OAAO,CACL,IAAW,EACX,GAAG,IAAwC,EAC3C,EAAE,CACF,QAAQ,CACN,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,WAAW,EACX,IAAI,CAAC,CAAC,CAAC,CACR,CAAA;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The failure codes the stack owns. A procedure cannot declare one of these. */
|
|
2
|
+
export declare const RESERVED_FAILURE_CODES: readonly ['UNAUTHENTICATED', 'DENIED', 'INVALID_INPUT', 'VALIDATION', 'RETRY', 'CONFLICT', 'INTERNAL'];
|
|
3
|
+
export type ReservedFailureCode = (typeof RESERVED_FAILURE_CODES)[number];
|
|
4
|
+
/** Whether `code` is one of the codes the stack owns. */
|
|
5
|
+
export declare function isReservedFailureCode(code: string): code is ReservedFailureCode;
|
|
6
|
+
export declare const FAILURE_STATUS: Readonly<Record<ReservedFailureCode, number>>;
|
|
7
|
+
/** What a procedure name is. A host serves no other. */
|
|
8
|
+
export declare const PROCEDURE_NAME_PATTERN: RegExp;
|
|
9
|
+
/** What a declared failure code is. */
|
|
10
|
+
export declare const DECLARED_FAILURE_CODE_PATTERN: RegExp;
|
|
11
|
+
/**
|
|
12
|
+
* The statuses the HTTP host refuses a request under before the pipeline
|
|
13
|
+
* runs, each answered `{ error: "<message>" }` rather than with the envelope.
|
|
14
|
+
*/
|
|
15
|
+
export declare const REFUSAL_STATUS: {
|
|
16
|
+
readonly NOT_FOUND: 404;
|
|
17
|
+
readonly METHOD_NOT_ALLOWED: 405;
|
|
18
|
+
readonly BODY_TOO_LARGE: 413;
|
|
19
|
+
readonly UNSUPPORTED_MEDIA_TYPE: 415;
|
|
20
|
+
};
|
|
21
|
+
/** Whether `status` is one the HTTP host refuses a request under. */
|
|
22
|
+
export declare function isRefusalStatus(status: number): boolean;
|
|
23
|
+
//# sourceMappingURL=codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/procedures/codes.ts"],"names":[],"mappings":"AAGA,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,YACjC,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,CACF,CAAA;AAEV,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAIzE,yDAAyD;AACzD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,mBAAmB,CAE/E;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAQxE,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,sBAAsB,QAAkC,CAAA;AAErE,uCAAuC;AACvC,eAAO,MAAM,6BAA6B,QAA2B,CAAA;AAErE;;;GAGG;AACH,eAAO,MAAM,cAAc;aACzB,SAAS,EAAE,GAAG;aACd,kBAAkB,EAAE,GAAG;aACvB,cAAc,EAAE,GAAG;aACnB,sBAAsB,EAAE,GAAG;CACnB,CAAA;AAIV,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The reserved failure codes, the host's refusal statuses and the name and code
|
|
2
|
+
// patterns. Imports nothing, so the browser client shares them with the host.
|
|
3
|
+
/** The failure codes the stack owns. A procedure cannot declare one of these. */
|
|
4
|
+
export const RESERVED_FAILURE_CODES = [
|
|
5
|
+
'UNAUTHENTICATED',
|
|
6
|
+
'DENIED',
|
|
7
|
+
'INVALID_INPUT',
|
|
8
|
+
'VALIDATION',
|
|
9
|
+
'RETRY',
|
|
10
|
+
'CONFLICT',
|
|
11
|
+
'INTERNAL',
|
|
12
|
+
];
|
|
13
|
+
const RESERVED = new Set(RESERVED_FAILURE_CODES);
|
|
14
|
+
/** Whether `code` is one of the codes the stack owns. */
|
|
15
|
+
export function isReservedFailureCode(code) {
|
|
16
|
+
return RESERVED.has(code);
|
|
17
|
+
}
|
|
18
|
+
export const FAILURE_STATUS = {
|
|
19
|
+
UNAUTHENTICATED: 401,
|
|
20
|
+
DENIED: 403,
|
|
21
|
+
INVALID_INPUT: 400,
|
|
22
|
+
VALIDATION: 400,
|
|
23
|
+
RETRY: 409,
|
|
24
|
+
CONFLICT: 409,
|
|
25
|
+
INTERNAL: 500,
|
|
26
|
+
};
|
|
27
|
+
/** What a procedure name is. A host serves no other. */
|
|
28
|
+
export const PROCEDURE_NAME_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;
|
|
29
|
+
/** What a declared failure code is. */
|
|
30
|
+
export const DECLARED_FAILURE_CODE_PATTERN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
31
|
+
/**
|
|
32
|
+
* The statuses the HTTP host refuses a request under before the pipeline
|
|
33
|
+
* runs, each answered `{ error: "<message>" }` rather than with the envelope.
|
|
34
|
+
*/
|
|
35
|
+
export const REFUSAL_STATUS = {
|
|
36
|
+
NOT_FOUND: 404,
|
|
37
|
+
METHOD_NOT_ALLOWED: 405,
|
|
38
|
+
BODY_TOO_LARGE: 413,
|
|
39
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
40
|
+
};
|
|
41
|
+
const REFUSALS = new Set(Object.values(REFUSAL_STATUS));
|
|
42
|
+
/** Whether `status` is one the HTTP host refuses a request under. */
|
|
43
|
+
export function isRefusalStatus(status) {
|
|
44
|
+
return REFUSALS.has(status);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src/procedures/codes.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,8EAA8E;AAE9E,iFAAiF;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,iBAAiB;IACjB,QAAQ;IACR,eAAe;IACf,YAAY;IACZ,OAAO;IACP,UAAU;IACV,UAAU;CACF,CAAA;AAIV,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAS,sBAAsB,CAAC,CAAA;AAE7E,yDAAyD;AACzD,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAkD;IAC3E,eAAe,EAAE,GAAG;IACpB,MAAM,EAAE,GAAG;IACX,aAAa,EAAE,GAAG;IAClB,UAAU,EAAE,GAAG;IACf,KAAK,EAAE,GAAG;IACV,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;CACd,CAAA;AAED,wDAAwD;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAA+B,CAAA;AAErE,uCAAuC;AACvC,MAAM,CAAC,MAAM,6BAA6B,GAAG,wBAAwB,CAAA;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS,EAAE,GAAG;IACd,kBAAkB,EAAE,GAAG;IACvB,cAAc,EAAE,GAAG;IACnB,sBAAsB,EAAE,GAAG;CACnB,CAAA;AAEV,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAA;AAEpF,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ProcedureContext, ProcedureHostContext, ProcedureHostTransactionContext } from './procedure.js';
|
|
2
|
+
/** The runtime-narrowed context a procedure is handed. See ADR-0086. */
|
|
3
|
+
export declare function procedureContextOf<C extends ProcedureHostContext<Tx>, Tx extends ProcedureHostTransactionContext>(context: C): ProcedureContext<C, Tx>;
|
|
4
|
+
//# sourceMappingURL=context-face.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-face.d.ts","sourceRoot":"","sources":["../../src/procedures/context-face.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,+BAA+B,EAEhC,MAAM,gBAAgB,CAAA;AAqBvB,wEAAwE;AACxE,wBAAgB,kBAAkB,CAChC,CAAC,SAAS,oBAAoB,CAAC,EAAE,CAAC,EAClC,EAAE,SAAS,+BAA+B,EAC1C,OAAO,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAarC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { throwReturnedFailure } from './failures.js';
|
|
2
|
+
function transactionContextOf(transaction) {
|
|
3
|
+
const face = Object.freeze({
|
|
4
|
+
db: transaction.db,
|
|
5
|
+
session: transaction.session,
|
|
6
|
+
storage: transaction.storage,
|
|
7
|
+
plugins: transaction.plugins,
|
|
8
|
+
advisoryLock: (key) => transaction.advisoryLock(key),
|
|
9
|
+
transaction: (fn) => transaction.transaction(async () => {
|
|
10
|
+
const result = await fn(face);
|
|
11
|
+
throwReturnedFailure(result);
|
|
12
|
+
return result;
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
return face;
|
|
16
|
+
}
|
|
17
|
+
/** The runtime-narrowed context a procedure is handed. See ADR-0086. */
|
|
18
|
+
export function procedureContextOf(context) {
|
|
19
|
+
return Object.freeze({
|
|
20
|
+
db: context.db,
|
|
21
|
+
session: context.session,
|
|
22
|
+
storage: context.storage,
|
|
23
|
+
plugins: context.plugins,
|
|
24
|
+
transaction: (fn) => context.transaction(async (transaction) => {
|
|
25
|
+
const result = await fn(transactionContextOf(transaction));
|
|
26
|
+
throwReturnedFailure(result);
|
|
27
|
+
return result;
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=context-face.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-face.js","sourceRoot":"","sources":["../../src/procedures/context-face.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAQpD,SAAS,oBAAoB,CAC3B,WAAe;IAEf,MAAM,IAAI,GAAoC,MAAM,CAAC,MAAM,CAAC;QAC1D,EAAE,EAAE,WAAW,CAAC,EAAE;QAClB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,YAAY,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC;QAC5D,WAAW,EAAE,CAAI,EAA8D,EAAE,EAAE,CACjF,WAAW,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE;YACjC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;YAC7B,oBAAoB,CAAC,MAAM,CAAC,CAAA;YAC5B,OAAO,MAAM,CAAA;QACf,CAAC,CAAC;KACL,CAAC,CAAA;IACF,OAAO,IAAI,CAAA;AACb,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,kBAAkB,CAGhC,OAAU;IACV,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE,EAAE,OAAO,CAAC,EAAE;QACd,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,WAAW,EAAE,CAAI,EAA8D,EAAE,EAAE,CACjF,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;YACxC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;YAC1D,oBAAoB,CAAC,MAAM,CAAC,CAAA;YAC5B,OAAO,MAAM,CAAA;QACf,CAAC,CAAC;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs one of a procedure's declared failures, for `run` to **throw**.
|
|
3
|
+
* Throwing is what rolls back an open transaction. A failure returned from
|
|
4
|
+
* `run` or from a `context.transaction` callback is treated as thrown.
|
|
5
|
+
*
|
|
6
|
+
* @param code - one of the codes the procedure declares in `failures`.
|
|
7
|
+
* @param message - replaces the declared message for this one failure.
|
|
8
|
+
*/
|
|
9
|
+
export type ProcedureFail<TCode extends string> = (code: TCode, message?: string) => ProcedureFailureError<TCode>;
|
|
10
|
+
/**
|
|
11
|
+
* A declared failure, as `fail` constructs it. A host answers one thrown by
|
|
12
|
+
* the procedure whose `fail` constructed it with `{ success: false, error: {
|
|
13
|
+
* code, message } }`; thrown anywhere else it is an unexpected error.
|
|
14
|
+
*/
|
|
15
|
+
export declare class ProcedureFailureError<TCode extends string = string> extends Error {
|
|
16
|
+
readonly code: TCode;
|
|
17
|
+
constructor(code: TCode, message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The code and message of a failure constructed by the `fail` of the procedure
|
|
21
|
+
* whose frozen `failures` object is given, or `undefined` for anything else.
|
|
22
|
+
*/
|
|
23
|
+
export declare function declaredFailureOf(error: unknown, failures: object): {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** Throws `value` when any procedure's `fail` constructed it, so a returned failure acts as a thrown one. */
|
|
28
|
+
export declare function throwReturnedFailure(value: unknown): void;
|
|
29
|
+
/** The `fail` helper for a procedure declaring `failures`. */
|
|
30
|
+
export declare function failWith<TCode extends string>(failures: Readonly<Partial<Record<TCode, string>>>): ProcedureFail<TCode>;
|
|
31
|
+
//# sourceMappingURL=failures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.d.ts","sourceRoot":"","sources":["../../src/procedures/failures.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,MAAM,IAAI,CAChD,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,MAAM,KACb,qBAAqB,CAAC,KAAK,CAAC,CAAA;AAEjC;;;;GAIG;AACH,qBAAa,qBAAqB,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IAC7E,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;IAEpB,YAAY,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAIvC;CACF;AAcD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GACf;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAI/C;AAED,6GAA6G;AAC7G,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAEzD;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,EAC3C,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GACjD,aAAa,CAAC,KAAK,CAAC,CAStB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { processGlobal } from '../lib/process-global.js';
|
|
2
|
+
/**
|
|
3
|
+
* A declared failure, as `fail` constructs it. A host answers one thrown by
|
|
4
|
+
* the procedure whose `fail` constructed it with `{ success: false, error: {
|
|
5
|
+
* code, message } }`; thrown anywhere else it is an unexpected error.
|
|
6
|
+
*/
|
|
7
|
+
export class ProcedureFailureError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
constructor(code, message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = 'ProcedureFailureError';
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function isWeakMap(value) {
|
|
16
|
+
return value instanceof WeakMap;
|
|
17
|
+
}
|
|
18
|
+
function failureOwners() {
|
|
19
|
+
return processGlobal('procedure-failure-owners', isWeakMap, () => new WeakMap());
|
|
20
|
+
}
|
|
21
|
+
function hasStringCode(value) {
|
|
22
|
+
return 'code' in value && typeof value.code === 'string';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The code and message of a failure constructed by the `fail` of the procedure
|
|
26
|
+
* whose frozen `failures` object is given, or `undefined` for anything else.
|
|
27
|
+
*/
|
|
28
|
+
export function declaredFailureOf(error, failures) {
|
|
29
|
+
if (!(error instanceof Error) || failureOwners().get(error) !== failures)
|
|
30
|
+
return undefined;
|
|
31
|
+
if (!hasStringCode(error) || !Object.hasOwn(failures, error.code))
|
|
32
|
+
return undefined;
|
|
33
|
+
return { code: error.code, message: error.message };
|
|
34
|
+
}
|
|
35
|
+
/** Throws `value` when any procedure's `fail` constructed it, so a returned failure acts as a thrown one. */
|
|
36
|
+
export function throwReturnedFailure(value) {
|
|
37
|
+
if (value instanceof Error && failureOwners().has(value))
|
|
38
|
+
throw value;
|
|
39
|
+
}
|
|
40
|
+
/** The `fail` helper for a procedure declaring `failures`. */
|
|
41
|
+
export function failWith(failures) {
|
|
42
|
+
return (code, message) => {
|
|
43
|
+
if (!Object.hasOwn(failures, code)) {
|
|
44
|
+
throw new Error(`Failure code ${JSON.stringify(code)} is not declared by this procedure.`);
|
|
45
|
+
}
|
|
46
|
+
const error = new ProcedureFailureError(code, message ?? failures[code] ?? code);
|
|
47
|
+
failureOwners().set(error, failures);
|
|
48
|
+
return error;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=failures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"failures.js","sourceRoot":"","sources":["../../src/procedures/failures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAexD;;;;GAIG;AACH,MAAM,OAAO,qBAAqD,SAAQ,KAAK;IACpE,IAAI,CAAO;IAEpB,YAAY,IAAW,EAAE,OAAe;QACtC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAA;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,YAAY,OAAO,CAAA;AACjC,CAAC;AAED,SAAS,aAAa;IACpB,OAAO,aAAa,CAAC,0BAA0B,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,EAAkB,CAAC,CAAA;AAClG,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAc,EACd,QAAgB;IAEhB,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,IAAI,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC1F,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IACnF,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;AACrD,CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,KAAK,YAAY,KAAK,IAAI,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,MAAM,KAAK,CAAA;AACvE,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,QAAQ,CACtB,QAAkD;IAElD,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QACvB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAA;QAC5F,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,qBAAqB,CAAC,IAAI,EAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAA;QAChF,aAAa,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QACpC,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { OpenSaasConfig } from '../config/types.js';
|
|
2
|
+
import type { ProcedureHostContext, ProcedureRegistry } from './procedure.js';
|
|
3
|
+
/** The session type an application context carries, without its `null`. */
|
|
4
|
+
export type SessionOf<C extends ProcedureHostContext> = Exclude<C['session'], null>;
|
|
5
|
+
/** Options for {@link createProcedureHandler}. */
|
|
6
|
+
export interface ProcedureHandlerOptions<C extends ProcedureHostContext> {
|
|
7
|
+
/** The application's procedure registry. Only procedures exposing `'web'` are reachable. */
|
|
8
|
+
procedures: ProcedureRegistry<C>;
|
|
9
|
+
/**
|
|
10
|
+
* The resolved config. Procedure names share one namespace with MCP tools,
|
|
11
|
+
* and with the config the host refuses a procedure named like one of its
|
|
12
|
+
* list custom tools or plugin-registered tools. A config with plugins is a
|
|
13
|
+
* promise, so pass `await config`. Without it only the reserved
|
|
14
|
+
* `list_<list>_<operation>` pattern is refused.
|
|
15
|
+
*/
|
|
16
|
+
config?: OpenSaasConfig;
|
|
17
|
+
/** The generated `getContext`: called with the resolved session, or with nothing when anonymous. */
|
|
18
|
+
getContext: (session?: SessionOf<C>) => Promise<C>;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the cookie session for a request. Called only when the request
|
|
21
|
+
* carries a `Cookie` header from an allowed origin, with a body-less `GET`
|
|
22
|
+
* copy of the request carrying its URL and headers; a request with no
|
|
23
|
+
* credential is anonymous without asking. Resolving `null` or `undefined`
|
|
24
|
+
* means no session; resolving anything else that is not an object fails
|
|
25
|
+
* the call with `INTERNAL` and is reported to `onUnexpectedError`.
|
|
26
|
+
*
|
|
27
|
+
* The host sets `session.actor` to a human actor carrying the session's
|
|
28
|
+
* `userId` as given, in place of any `actor` the resolved session holds.
|
|
29
|
+
* `userId` must be an own data property (not a getter) of the session holding a non-empty
|
|
30
|
+
* string or a finite number; otherwise the call fails with `INTERNAL` and
|
|
31
|
+
* the cause is reported to `onUnexpectedError`. The session handed to
|
|
32
|
+
* `getContext` is a copy that keeps the resolved object's prototype.
|
|
33
|
+
*/
|
|
34
|
+
getSession: (request: Request) => Promise<SessionOf<C> | null | undefined>;
|
|
35
|
+
/**
|
|
36
|
+
* The origins a cookie-authenticated request may come from, as absolute
|
|
37
|
+
* URLs (`https://app.example.com`). A request carrying a cookie from any
|
|
38
|
+
* other origin, or from none, is refused.
|
|
39
|
+
*/
|
|
40
|
+
allowedOrigins: readonly string[];
|
|
41
|
+
/** The path the routes are mounted under; each procedure is `POST <basePath>/<name>`. Default `/api/procedures`. */
|
|
42
|
+
basePath?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The largest request body accepted, in bytes. Default 1 MiB. The body is
|
|
45
|
+
* read only once the access rule has admitted the call.
|
|
46
|
+
*/
|
|
47
|
+
maxBodyBytes?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Told of every failure the operator should see, with the procedure's name:
|
|
50
|
+
* every error whose message is withheld from the caller, every database
|
|
51
|
+
* failure other than a unique-constraint violation or a serialization
|
|
52
|
+
* failure (the driver's detail is on `error.cause`), and every engine
|
|
53
|
+
* refusal of a payload the procedure itself wrote. Default `console.error`,
|
|
54
|
+
* which is also the fallback when this function throws or returns a promise
|
|
55
|
+
* that rejects.
|
|
56
|
+
*/
|
|
57
|
+
onUnexpectedError?: (error: unknown, procedureName: string) => void;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A web-standard `Request` → `Response` handler that serves an application's
|
|
61
|
+
* procedures over HTTP: `POST <basePath>/<name>`, JSON in and JSON out. It
|
|
62
|
+
* runs under any framework that speaks the Fetch API.
|
|
63
|
+
*
|
|
64
|
+
* Identity comes from the host alone. A request with no credential is
|
|
65
|
+
* anonymous and the procedure's access rule decides; a request with a cookie
|
|
66
|
+
* must come from an allowed origin and is resolved by `getSession`; a request
|
|
67
|
+
* carrying an `Authorization` header is refused, with or without a cookie.
|
|
68
|
+
* Nothing in the body can supply a session. A resolved session carries a human
|
|
69
|
+
* `actor`, which the host sets itself.
|
|
70
|
+
*
|
|
71
|
+
* A call that reaches the pipeline answers with the result envelope:
|
|
72
|
+
* `{ success: true, data }`, or `{ success: false, error: { code, message,
|
|
73
|
+
* fieldErrors? } }` with `UNAUTHENTICATED` 401, `DENIED` 403,
|
|
74
|
+
* `INVALID_INPUT`/`VALIDATION` 400, `RETRY`/`CONFLICT` 409 and `INTERNAL` 500.
|
|
75
|
+
* A failure the procedure declares is an expected outcome and answers 200
|
|
76
|
+
* with its own code. The host never retries a call: `RETRY` reports that the
|
|
77
|
+
* transaction rolled back and leaves running it again to the caller.
|
|
78
|
+
* An unexpected error's message is passed to `onUnexpectedError` and never to
|
|
79
|
+
* the client. An empty or missing body is `undefined` input, which the input
|
|
80
|
+
* schema accepts or refuses; a body that is not JSON is `INVALID_INPUT`.
|
|
81
|
+
*
|
|
82
|
+
* A transport failure does not use the envelope. It answers
|
|
83
|
+
* `{ error: "<message>" }`, where `error` is a string: 404 for an unknown name
|
|
84
|
+
* or a procedure not exposed to `'web'` (the two are indistinguishable), 405
|
|
85
|
+
* for a method other than `POST`, 415 for a content type other than
|
|
86
|
+
* `application/json`, and 413 for a body over `maxBodyBytes`. A client should
|
|
87
|
+
* branch on the status before reading `success`.
|
|
88
|
+
*
|
|
89
|
+
* The host refuses, when it is created, a registry it cannot serve safely: a
|
|
90
|
+
* schema that cannot be carried on the wire or accepts open-ended values, a
|
|
91
|
+
* name that clashes with an MCP tool, and a procedure declaring a reserved
|
|
92
|
+
* failure code. See {@link assertProcedureRegistry}.
|
|
93
|
+
*
|
|
94
|
+
* @throws {ProcedureHostError} for an invalid option, name, schema or registry entry,
|
|
95
|
+
* or a procedure declaring a reserved failure code.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // app/api/procedures/[name]/route.ts
|
|
100
|
+
* import { createProcedureHandler } from '@opensaas/stack-core/procedures'
|
|
101
|
+
* import { getContext } from '@/.opensaas/context'
|
|
102
|
+
* import { procedures } from '@/lib/procedures'
|
|
103
|
+
* import { getSession } from '@/lib/auth'
|
|
104
|
+
*
|
|
105
|
+
* export const POST = createProcedureHandler({
|
|
106
|
+
* procedures,
|
|
107
|
+
* getContext,
|
|
108
|
+
* getSession: (request) => getSession(request.headers),
|
|
109
|
+
* allowedOrigins: [process.env.APP_ORIGIN ?? 'http://localhost:3000'],
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
export declare function createProcedureHandler<C extends ProcedureHostContext>(options: ProcedureHandlerOptions<C>): (request: Request) => Promise<Response>;
|
|
114
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/procedures/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAM7E,2EAA2E;AAC3E,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,oBAAoB,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAA;AAEnF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS,oBAAoB;IACrE,4FAA4F;IAC5F,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAA;IAChC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;IACvB,oGAAoG;IACpG,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;IAClD;;;;;;;;;;;;;;OAcG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAA;IAC1E;;;;OAIG;IACH,cAAc,EAAE,SAAS,MAAM,EAAE,CAAA;IACjC,oHAAoH;IACpH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE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