@vibesdotdev/infra-contracts 0.0.0-stage → 1.0.0-rc.6
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 +18 -0
- package/README.md +57 -2
- package/dist/docs/plugin.d.ts +3 -0
- package/dist/docs/plugin.d.ts.map +1 -0
- package/dist/docs/plugin.js +9 -0
- package/dist/docs/plugin.js.map +1 -0
- package/dist/docs/service.docs.descriptor.d.ts +17 -0
- package/dist/docs/service.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/service.docs.descriptor.js +61 -0
- package/dist/docs/service.docs.descriptor.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/service.d.ts +103 -0
- package/dist/schemas/service.d.ts.map +1 -0
- package/dist/schemas/service.js +42 -0
- package/dist/schemas/service.js.map +1 -0
- package/dist/service.d.ts +14 -0
- package/dist/service.d.ts.map +1 -0
- package/dist/service.js +34 -0
- package/dist/service.js.map +1 -0
- package/package.json +106 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VIBES DEV LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vibesdotdev/infra-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Portable service descriptors and typed target ports. Public MIT package.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
bun add @vibesdotdev/infra-contracts
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { ServiceTargetSchema, type ServicePort } from '@vibesdotdev/infra-contracts';
|
|
11
|
+
|
|
12
|
+
async function primaryOrigin(service: ServicePort): Promise<string> {
|
|
13
|
+
return ServiceTargetSchema.parse(await service.target('primary')).origin;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The root, `/service` and `/schemas` export the same canonical service schemas
|
|
18
|
+
and inferred types. Node loads built ESM; TypeScript consumes emitted
|
|
19
|
+
declarations; Bun supports source entrypoints. The primary contract depends at
|
|
20
|
+
runtime on the kernel and Zod. The docs contract is a type-only dependency.
|
|
21
|
+
|
|
22
|
+
Descriptors and targets reject malformed values with Zod errors. Primary/internal
|
|
23
|
+
origins cannot repeat in one environment; aliases default to []. Plain ports
|
|
24
|
+
validate optional target-kind arguments and promised results. Implementation
|
|
25
|
+
errors propagate unchanged. Keep the original receiver when calling resolved
|
|
26
|
+
class methods: a parsed plain port is not a class adapter.
|
|
27
|
+
|
|
28
|
+
`serviceOrigin` from `@vibesdotdev/infra-contracts/service` reads that target
|
|
29
|
+
through the handed runtime. Invalid ids, invalid kinds, and undeclared
|
|
30
|
+
services refuse with `CapabilityError` and do not echo the caller value.
|
|
31
|
+
`@vibesdotdev/infra-core` owns service registration, configuration, environment
|
|
32
|
+
selection, and implementations.
|
|
33
|
+
|
|
34
|
+
## Documentation discovery
|
|
35
|
+
|
|
36
|
+
Select `docsPlugin` from `@vibesdotdev/docs/plugin` and
|
|
37
|
+
`infraContractsDocsPlugin` from `@vibesdotdev/infra-contracts/docs` in your
|
|
38
|
+
runtime composition. The docs owner registers the kind; this package adds its
|
|
39
|
+
topic. Documentation stays outside the primary barrel.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { getVibesDocsClient } from '@vibesdotdev/docs';
|
|
43
|
+
|
|
44
|
+
const docs = await getVibesDocsClient(runtime);
|
|
45
|
+
const topic = docs.findById('infra-contracts.service');
|
|
46
|
+
if (topic) console.log(docs.resolveBody(topic));
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Run `bun run check`, `bun run test` and `bun run build` in this package.
|
|
50
|
+
Tests import all four public package entrypoints, check exact manifest mappings
|
|
51
|
+
and publication exclusions, and exercise real docs discovery. Typecheck verifies
|
|
52
|
+
source inference; local source scans inspect direct imports. Build/export checks
|
|
53
|
+
and release preflight own emitted-declaration consumption and transitive closure
|
|
54
|
+
verification; release preflight verifies actual published files. No packing,
|
|
55
|
+
extraction or subprocess installs run inside `bun test`.
|
|
56
|
+
The publication manifest excludes tests and compiler state.
|
|
57
|
+
|
|
58
|
+
See [SPEC.md](./SPEC.md) and [LICENSE](./LICENSE).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/docs/plugin.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,6CAInC,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRuntimePlugin } from '@vibesdotdev/kernel';
|
|
2
|
+
import serviceTopic from "./service.docs.descriptor.js";
|
|
3
|
+
export const infraContractsDocsPlugin = createRuntimePlugin({
|
|
4
|
+
id: 'infra-contracts.docs',
|
|
5
|
+
name: 'Infrastructure contract documentation',
|
|
6
|
+
descriptors: [serviceTopic]
|
|
7
|
+
});
|
|
8
|
+
export default infraContractsDocsPlugin;
|
|
9
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/docs/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,YAAY,MAAM,8BAA8B,CAAC;AAExD,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;IAC3D,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,uCAAuC;IAC7C,WAAW,EAAE,CAAC,YAAY,CAAC;CAC3B,CAAC,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
kind: "docs/topic";
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
summary: string;
|
|
6
|
+
track: "api-reference";
|
|
7
|
+
tags: string[];
|
|
8
|
+
surfaces: ("cli" | "mcp" | "web" | "in-app")[];
|
|
9
|
+
enabled: true;
|
|
10
|
+
body: {
|
|
11
|
+
type: "markdown";
|
|
12
|
+
sourceType: "raw";
|
|
13
|
+
source: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
17
|
+
//# sourceMappingURL=service.docs.descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.docs.descriptor.d.ts","sourceRoot":"","sources":["../../src/docs/service.docs.descriptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,wBA2DgC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
kind: 'docs/topic',
|
|
3
|
+
id: 'infra-contracts.service',
|
|
4
|
+
title: 'Portable infrastructure service contracts',
|
|
5
|
+
summary: 'Service descriptors, target validation, public entrypoints and owner boundaries.',
|
|
6
|
+
track: 'api-reference',
|
|
7
|
+
tags: ['infra-contracts', 'infra', 'service'],
|
|
8
|
+
surfaces: ['cli', 'web', 'in-app', 'mcp'],
|
|
9
|
+
enabled: true,
|
|
10
|
+
body: {
|
|
11
|
+
type: 'markdown',
|
|
12
|
+
sourceType: 'raw',
|
|
13
|
+
source: `# Infrastructure service contracts
|
|
14
|
+
|
|
15
|
+
Install with \`bun add @vibesdotdev/infra-contracts\` (MIT).
|
|
16
|
+
The root, \`/service\` and \`/schemas\` export the same canonical schemas
|
|
17
|
+
and inferred types. Canonical definitions live in \`src/schemas/\`.
|
|
18
|
+
|
|
19
|
+
\`ServiceDescriptorSchema\` admits strict infra/service descriptors with nonempty
|
|
20
|
+
origins and defaults aliases to []. Origins reuse the kernel EnvironmentTierSchema;
|
|
21
|
+
primary and internal origins cannot repeat within one environment. Duplicate
|
|
22
|
+
refusals identify the offending origins index. Unknown fields, invalid URLs,
|
|
23
|
+
empty aliases and unsupported environments are Zod schema refusals.
|
|
24
|
+
|
|
25
|
+
\`ServiceTargetSchema\` validates a strict origin URL and selected environment.
|
|
26
|
+
\`ServicePortSchema\` validates a plain target function: an optional primary or
|
|
27
|
+
internal kind returns a promise of a valid target. Invalid arguments are refused
|
|
28
|
+
before invocation; invalid results are refused after resolution. Implementation
|
|
29
|
+
errors propagate unchanged. Retain resolved class receivers:
|
|
30
|
+
|
|
31
|
+
\`\`\`ts
|
|
32
|
+
import { ServiceTargetSchema, type ServicePort } from '@vibesdotdev/infra-contracts';
|
|
33
|
+
async function origin(service: ServicePort) {
|
|
34
|
+
return ServiceTargetSchema.parse(await service.target('primary')).origin;
|
|
35
|
+
}
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
The parsed plain port is not a receiver-preserving class adapter.
|
|
39
|
+
\`serviceOrigin\` from \`@vibesdotdev/infra-contracts/service\` validates the id
|
|
40
|
+
and kind, then reads the handed runtime. An invalid id or kind, or an
|
|
41
|
+
undeclared service, refuses with CapabilityError and does not echo the caller
|
|
42
|
+
value. Implementation failures propagate unchanged.
|
|
43
|
+
@vibesdotdev/infra-core owns infra/service registration, implementations,
|
|
44
|
+
configuration and environment selection.
|
|
45
|
+
|
|
46
|
+
Compose docsPlugin from @vibesdotdev/docs/plugin and infraContractsDocsPlugin
|
|
47
|
+
from @vibesdotdev/infra-contracts/docs. Resolve getVibesDocsClient(runtime) from
|
|
48
|
+
@vibesdotdev/docs, findById('infra-contracts.service'), and resolveBody(topic).
|
|
49
|
+
The docs owner registers docs/topic; this package contributes only this topic.
|
|
50
|
+
Documentation composition is absent from the primary contract barrel.
|
|
51
|
+
|
|
52
|
+
Run bun run check, bun run test and bun run build in the package. In-process
|
|
53
|
+
tests import all four public entrypoints, compare canonical schemas, check exact
|
|
54
|
+
manifest mappings and publication exclusions, scan direct source imports, and
|
|
55
|
+
resolve docs through the runtime client. Typecheck verifies source inference.
|
|
56
|
+
Build/export checks and release preflight own emitted-declaration consumption
|
|
57
|
+
and transitive closure verification. Release preflight verifies published files.
|
|
58
|
+
`
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=service.docs.descriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.docs.descriptor.js","sourceRoot":"","sources":["../../src/docs/service.docs.descriptor.ts"],"names":[],"mappings":"AAEA,eAAe;IACd,IAAI,EAAE,YAAY;IAClB,EAAE,EAAE,yBAAyB;IAC7B,KAAK,EAAE,2CAA2C;IAClD,OAAO,EAAE,kFAAkF;IAC3F,KAAK,EAAE,eAAe;IACtB,IAAI,EAAE,CAAC,iBAAiB,EAAE,OAAO,EAAE,SAAS,CAAC;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC;IACzC,OAAO,EAAE,IAAI;IACb,IAAI,EAAE;QACL,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6CT;KACC;CAC6B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { EnvironmentTierSchema } from '@vibesdotdev/kernel/schemas/scope';
|
|
3
|
+
export declare const deploymentOriginKindSchema: z.ZodEnum<{
|
|
4
|
+
internal: "internal";
|
|
5
|
+
primary: "primary";
|
|
6
|
+
redirect: "redirect";
|
|
7
|
+
preview: "preview";
|
|
8
|
+
alias: "alias";
|
|
9
|
+
}>;
|
|
10
|
+
export type DeploymentOriginKind = z.infer<typeof deploymentOriginKindSchema>;
|
|
11
|
+
export declare const ServiceOriginSchema: z.ZodObject<{
|
|
12
|
+
environment: z.ZodEnum<{
|
|
13
|
+
local: "local";
|
|
14
|
+
dev: "dev";
|
|
15
|
+
staging: "staging";
|
|
16
|
+
production: "production";
|
|
17
|
+
}>;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
internal: "internal";
|
|
20
|
+
primary: "primary";
|
|
21
|
+
redirect: "redirect";
|
|
22
|
+
preview: "preview";
|
|
23
|
+
alias: "alias";
|
|
24
|
+
}>;
|
|
25
|
+
origin: z.ZodURL;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export declare const ServiceDescriptorSchema: z.ZodObject<{
|
|
28
|
+
id: z.ZodString;
|
|
29
|
+
name: z.ZodOptional<z.ZodString>;
|
|
30
|
+
description: z.ZodOptional<z.ZodString>;
|
|
31
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
hardware: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
capabilityId: z.ZodOptional<z.ZodString>;
|
|
36
|
+
requiredContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
optionalContext: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
+
config: z.ZodOptional<z.ZodUnknown>;
|
|
39
|
+
retention: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
40
|
+
maxAgeDays: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
maxEntries: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
cascadeFrom: z.ZodOptional<z.ZodString>;
|
|
44
|
+
ageField: z.ZodOptional<z.ZodString>;
|
|
45
|
+
reason: z.ZodString;
|
|
46
|
+
enforcedBy: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>]>>;
|
|
48
|
+
kind: z.ZodLiteral<"infra/service">;
|
|
49
|
+
origins: z.ZodArray<z.ZodObject<{
|
|
50
|
+
environment: z.ZodEnum<{
|
|
51
|
+
local: "local";
|
|
52
|
+
dev: "dev";
|
|
53
|
+
staging: "staging";
|
|
54
|
+
production: "production";
|
|
55
|
+
}>;
|
|
56
|
+
kind: z.ZodEnum<{
|
|
57
|
+
internal: "internal";
|
|
58
|
+
primary: "primary";
|
|
59
|
+
redirect: "redirect";
|
|
60
|
+
preview: "preview";
|
|
61
|
+
alias: "alias";
|
|
62
|
+
}>;
|
|
63
|
+
origin: z.ZodURL;
|
|
64
|
+
}, z.core.$strict>>;
|
|
65
|
+
aliases: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
66
|
+
cookieDomain: z.ZodOptional<z.ZodString>;
|
|
67
|
+
sshHost: z.ZodOptional<z.ZodString>;
|
|
68
|
+
sshHostKey: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
export type ServiceDescriptor = z.infer<typeof ServiceDescriptorSchema>;
|
|
71
|
+
export type ServiceEnvironment = z.infer<typeof EnvironmentTierSchema>;
|
|
72
|
+
export declare const ServiceTargetKindSchema: z.ZodEnum<{
|
|
73
|
+
internal: "internal";
|
|
74
|
+
primary: "primary";
|
|
75
|
+
}>;
|
|
76
|
+
export type ServiceTargetKind = z.infer<typeof ServiceTargetKindSchema>;
|
|
77
|
+
export declare const ServiceTargetSchema: z.ZodObject<{
|
|
78
|
+
origin: z.ZodURL;
|
|
79
|
+
environment: z.ZodEnum<{
|
|
80
|
+
local: "local";
|
|
81
|
+
dev: "dev";
|
|
82
|
+
staging: "staging";
|
|
83
|
+
production: "production";
|
|
84
|
+
}>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
export type ServiceTarget = z.infer<typeof ServiceTargetSchema>;
|
|
87
|
+
/** Validate a plain port; runtime consumers retain implementation receivers and validate returned targets. */
|
|
88
|
+
export declare const ServicePortSchema: z.ZodObject<{
|
|
89
|
+
target: z.ZodFunction<z.ZodTuple<readonly [z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
internal: "internal";
|
|
91
|
+
primary: "primary";
|
|
92
|
+
}>>], null>, z.ZodPromise<z.ZodObject<{
|
|
93
|
+
origin: z.ZodURL;
|
|
94
|
+
environment: z.ZodEnum<{
|
|
95
|
+
local: "local";
|
|
96
|
+
dev: "dev";
|
|
97
|
+
staging: "staging";
|
|
98
|
+
production: "production";
|
|
99
|
+
}>;
|
|
100
|
+
}, z.core.$strict>>>;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
export type ServicePort = z.infer<typeof ServicePortSchema>;
|
|
103
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/schemas/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,eAAO,MAAM,0BAA0B;;;;;;EAAkE,CAAC;AAC1G,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;kBAI9B,CAAC;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmBlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEvE,eAAO,MAAM,uBAAuB;;;EAAkC,CAAC;AACvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,mBAAmB;;;;;;;;kBAG9B,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,8GAA8G;AAC9G,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;iBAK5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { RuntimeDescriptorSchema } from '@vibesdotdev/kernel/schemas/descriptor';
|
|
3
|
+
import { EnvironmentTierSchema } from '@vibesdotdev/kernel/schemas/scope';
|
|
4
|
+
export const deploymentOriginKindSchema = z.enum(['primary', 'redirect', 'preview', 'internal', 'alias']);
|
|
5
|
+
export const ServiceOriginSchema = z.strictObject({
|
|
6
|
+
environment: EnvironmentTierSchema,
|
|
7
|
+
kind: deploymentOriginKindSchema,
|
|
8
|
+
origin: z.url()
|
|
9
|
+
});
|
|
10
|
+
export const ServiceDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
11
|
+
kind: z.literal('infra/service'),
|
|
12
|
+
origins: z.array(ServiceOriginSchema).min(1),
|
|
13
|
+
aliases: z.array(z.string().min(1)).default([]),
|
|
14
|
+
cookieDomain: z.string().optional(),
|
|
15
|
+
sshHost: z.string().optional(),
|
|
16
|
+
sshHostKey: z.string().optional()
|
|
17
|
+
}).strict().superRefine((service, context) => {
|
|
18
|
+
const keys = new Set();
|
|
19
|
+
for (const [index, origin] of service.origins.entries()) {
|
|
20
|
+
const key = `${origin.environment}:${origin.kind}`;
|
|
21
|
+
if (keys.has(key) && (origin.kind === 'primary' || origin.kind === 'internal')) {
|
|
22
|
+
context.addIssue({
|
|
23
|
+
code: 'custom', path: ['origins', index],
|
|
24
|
+
message: 'A service has one primary or internal origin per environment.'
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
keys.add(key);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
export const ServiceTargetKindSchema = z.enum(['primary', 'internal']);
|
|
31
|
+
export const ServiceTargetSchema = z.strictObject({
|
|
32
|
+
origin: z.url(),
|
|
33
|
+
environment: EnvironmentTierSchema
|
|
34
|
+
});
|
|
35
|
+
/** Validate a plain port; runtime consumers retain implementation receivers and validate returned targets. */
|
|
36
|
+
export const ServicePortSchema = z.object({
|
|
37
|
+
target: z.function({
|
|
38
|
+
input: [ServiceTargetKindSchema.optional()],
|
|
39
|
+
output: z.promise(ServiceTargetSchema)
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/schemas/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;AAG1G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE,0BAA0B;IAChC,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE;CACf,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,uBAAuB,CAAC,MAAM,CAAC;IACrE,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,C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AAE,qBAAqB;CAClC,CAAC,CAAC;AAGH,8GAA8G;AAC9G,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC;QAClB,KAAK,EAAE,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC;QAC3C,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;KACtC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RuntimeRef } from '@vibesdotdev/kernel';
|
|
2
|
+
import { type ServiceTargetKind } from './schemas/index.ts';
|
|
3
|
+
export * from './schemas/index.ts';
|
|
4
|
+
/**
|
|
5
|
+
* A declared service's origin, read through the `infra/service` kind. The
|
|
6
|
+
* kind's implementation (infra-core's by default) selects the target, so a
|
|
7
|
+
* consumer needs only this contract and the runtime it was handed.
|
|
8
|
+
*
|
|
9
|
+
* Caller values stay out of the refusal: invalid ids and kinds are rejected
|
|
10
|
+
* before the query, and an undeclared service names no id in the message,
|
|
11
|
+
* details, or cause.
|
|
12
|
+
*/
|
|
13
|
+
export declare function serviceOrigin(runtime: RuntimeRef, id: string, kind?: ServiceTargetKind): Promise<string>;
|
|
14
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAA0F,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEpJ,cAAc,oBAAoB,CAAC;AAEnC;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,GAAE,iBAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBzH"}
|
package/dist/service.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CapabilityError } from '@vibesdotdev/kernel';
|
|
2
|
+
import { SafeIdentifierSchema } from '@vibesdotdev/kernel/schemas/descriptor';
|
|
3
|
+
import { ServiceTargetKindSchema, ServiceTargetSchema } from "./schemas/index.js";
|
|
4
|
+
export * from "./schemas/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* A declared service's origin, read through the `infra/service` kind. The
|
|
7
|
+
* kind's implementation (infra-core's by default) selects the target, so a
|
|
8
|
+
* consumer needs only this contract and the runtime it was handed.
|
|
9
|
+
*
|
|
10
|
+
* Caller values stay out of the refusal: invalid ids and kinds are rejected
|
|
11
|
+
* before the query, and an undeclared service names no id in the message,
|
|
12
|
+
* details, or cause.
|
|
13
|
+
*/
|
|
14
|
+
export async function serviceOrigin(runtime, id, kind = 'primary') {
|
|
15
|
+
const serviceId = SafeIdentifierSchema.safeParse(id);
|
|
16
|
+
if (!serviceId.success)
|
|
17
|
+
throw new CapabilityError('Service id is invalid.', 'INVALID_INPUT', {
|
|
18
|
+
reason: 'service-id-invalid'
|
|
19
|
+
});
|
|
20
|
+
const targetKind = ServiceTargetKindSchema.safeParse(kind);
|
|
21
|
+
if (!targetKind.success)
|
|
22
|
+
throw new CapabilityError('Service target kind is invalid.', 'INVALID_INPUT', {
|
|
23
|
+
reason: 'service-target-kind-invalid'
|
|
24
|
+
});
|
|
25
|
+
const selected = runtime.hasKind('infra/service')
|
|
26
|
+
? await runtime.query('infra/service').withId(serviceId.data).select()
|
|
27
|
+
: undefined;
|
|
28
|
+
if (!selected)
|
|
29
|
+
throw new CapabilityError('Service is not declared in this runtime.', 'NOT_FOUND', {
|
|
30
|
+
reason: 'service-undeclared'
|
|
31
|
+
});
|
|
32
|
+
return ServiceTargetSchema.parse(await selected.impl.target(targetKind.data)).origin;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.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,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,108 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibesdotdev/infra-contracts",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-rc.6",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@vibesdotdev/kernel": "^1.0.0-rc.11",
|
|
6
|
+
"zod": "^4.6.7",
|
|
7
|
+
"@vibesdotdev/docs-contracts": "^1.0.0-rc.5"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"bun": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./service": {
|
|
18
|
+
"bun": "./dist/service.js",
|
|
19
|
+
"types": "./dist/service.d.ts",
|
|
20
|
+
"import": "./dist/service.js",
|
|
21
|
+
"default": "./dist/service.js"
|
|
22
|
+
},
|
|
23
|
+
"./schemas": {
|
|
24
|
+
"bun": "./dist/schemas/index.js",
|
|
25
|
+
"types": "./dist/schemas/index.d.ts",
|
|
26
|
+
"import": "./dist/schemas/index.js",
|
|
27
|
+
"default": "./dist/schemas/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./docs": {
|
|
30
|
+
"bun": "./dist/docs/plugin.js",
|
|
31
|
+
"types": "./dist/docs/plugin.d.ts",
|
|
32
|
+
"import": "./dist/docs/plugin.js",
|
|
33
|
+
"default": "./dist/docs/plugin.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"!dist/**/__tests__/**",
|
|
41
|
+
"!dist/**/*.test.js",
|
|
42
|
+
"!dist/**/*.test.d.ts",
|
|
43
|
+
"!dist/**/*.spec.js",
|
|
44
|
+
"!dist/**/*.spec.d.ts",
|
|
45
|
+
"!dist/**/*.tsbuildinfo",
|
|
46
|
+
"!**/.turbo/**",
|
|
47
|
+
"!**/.svelte-kit/**",
|
|
48
|
+
"!**/.vibes/**",
|
|
49
|
+
"!**/__tests__/**",
|
|
50
|
+
"!**/__stubs__/**",
|
|
51
|
+
"!**/*.test.js",
|
|
52
|
+
"!**/*.test.mjs",
|
|
53
|
+
"!**/*.test.cjs",
|
|
54
|
+
"!**/*.test.jsx",
|
|
55
|
+
"!**/*.test.ts",
|
|
56
|
+
"!**/*.test.mts",
|
|
57
|
+
"!**/*.test.cts",
|
|
58
|
+
"!**/*.test.tsx",
|
|
59
|
+
"!**/*.spec.js",
|
|
60
|
+
"!**/*.spec.mjs",
|
|
61
|
+
"!**/*.spec.cjs",
|
|
62
|
+
"!**/*.spec.jsx",
|
|
63
|
+
"!**/*.spec.ts",
|
|
64
|
+
"!**/*.spec.mts",
|
|
65
|
+
"!**/*.spec.cts",
|
|
66
|
+
"!**/*.spec.tsx",
|
|
67
|
+
"!**/SPEC.md",
|
|
68
|
+
"!**/tsconfig.json",
|
|
69
|
+
"!**/tsconfig.*.json",
|
|
70
|
+
"!**/*.tsbuildinfo",
|
|
71
|
+
"!**/.build-ok.json",
|
|
72
|
+
"!**/*.tgz"
|
|
73
|
+
],
|
|
74
|
+
"scripts": {
|
|
75
|
+
"lint": "node ../node_modules/@vibesdotdev/internal-oxlint-toolchain/ratchet.mjs .",
|
|
76
|
+
"build": "${BUN:-bun} --bun tsc -p tsconfig.json",
|
|
77
|
+
"check": "${BUN:-bun} --bun tsc -p tsconfig.check.json",
|
|
78
|
+
"test": "${BUN:-bun} test src"
|
|
79
|
+
},
|
|
80
|
+
"repository": {
|
|
81
|
+
"type": "git",
|
|
82
|
+
"url": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
|
|
83
|
+
"directory": "infra-contracts"
|
|
84
|
+
},
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"registry": "https://packages.vibes.dev",
|
|
87
|
+
"access": "public"
|
|
88
|
+
},
|
|
89
|
+
"vibes": {
|
|
90
|
+
"visibility": "public",
|
|
91
|
+
"registry": {
|
|
92
|
+
"repositoryId": "4b1374d4-6830-4bfd-98e3-de66416368a8",
|
|
93
|
+
"directory": "infra-contracts"
|
|
94
|
+
},
|
|
95
|
+
"publishLoadRuntime": "node",
|
|
96
|
+
"handedRuntimeLogging": true
|
|
97
|
+
},
|
|
98
|
+
"description": "Portable infrastructure service descriptors and target port contracts.",
|
|
99
|
+
"type": "module",
|
|
100
|
+
"types": "./dist/index.d.ts",
|
|
101
|
+
"license": "MIT",
|
|
102
|
+
"gitHead": "d1948c757f179d2c3fb41553347085335cb76710",
|
|
103
|
+
"_vibes_source": {
|
|
104
|
+
"repo": "ssh://git@git.vibes.dev/vibesdotdev/framework.git",
|
|
105
|
+
"sha": "d1948c757f179d2c3fb41553347085335cb76710",
|
|
106
|
+
"workspaceDigest": "sha256:44321e8f358fedf741daff2c84e5b4ce3aafe7c04ae53a5537e60613aee4fd2d"
|
|
107
|
+
}
|
|
108
|
+
}
|