@toa.io/definitions 1.0.0-alpha.292 → 1.0.0-alpha.293

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/digest/extensions.exposition.json +1 -1
  2. package/package.json +24 -7
  3. package/readme.md +1 -0
  4. package/transpiled/bridges.node/exports.js +25 -2
  5. package/transpiled/bridges.node/exports.js.map +1 -1
  6. package/transpiled/digest/generate.js +23 -3
  7. package/transpiled/digest/generate.js.map +1 -1
  8. package/transpiled/digest/read.d.ts +8 -0
  9. package/transpiled/digest/read.js +11 -0
  10. package/transpiled/digest/read.js.map +1 -1
  11. package/transpiled/extensions.exposition/index.d.ts +1 -0
  12. package/transpiled/extensions.exposition/index.js +1 -0
  13. package/transpiled/extensions.exposition/index.js.map +1 -1
  14. package/transpiled/extensions.exposition/packages.d.ts +11 -0
  15. package/transpiled/extensions.exposition/packages.js +17 -0
  16. package/transpiled/extensions.exposition/packages.js.map +1 -0
  17. package/transpiled/extensions.storages/index.d.ts +1 -0
  18. package/transpiled/extensions.storages/index.js +1 -0
  19. package/transpiled/extensions.storages/index.js.map +1 -1
  20. package/transpiled/extensions.storages/packages.d.ts +19 -0
  21. package/transpiled/extensions.storages/packages.js +41 -0
  22. package/transpiled/extensions.storages/packages.js.map +1 -0
  23. package/CHANGELOG.md +0 -13
  24. package/source/bindings.amqp/annotation.ts +0 -26
  25. package/source/bindings.amqp/context.ts +0 -68
  26. package/source/bindings.amqp/deployment.ts +0 -14
  27. package/source/bindings.amqp/index.ts +0 -9
  28. package/source/bindings.amqp/instance.ts +0 -3
  29. package/source/bindings.amqp/sources.ts +0 -39
  30. package/source/bindings.loop/index.ts +0 -3
  31. package/source/bridges.bash/const.ts +0 -2
  32. package/source/bridges.bash/define.ts +0 -38
  33. package/source/bridges.bash/index.ts +0 -2
  34. package/source/bridges.node/define.ts +0 -69
  35. package/source/bridges.node/exports.ts +0 -175
  36. package/source/bridges.node/index.ts +0 -6
  37. package/source/bridges.node/operations.ts +0 -127
  38. package/source/bridges.node/sources.ts +0 -44
  39. package/source/definition.ts +0 -38
  40. package/source/digest/generate.ts +0 -77
  41. package/source/digest/read.ts +0 -39
  42. package/source/extensions.cadence/components.ts +0 -6
  43. package/source/extensions.cadence/const.ts +0 -31
  44. package/source/extensions.cadence/context.ts +0 -10
  45. package/source/extensions.cadence/deployment.ts +0 -37
  46. package/source/extensions.cadence/index.ts +0 -8
  47. package/source/extensions.cadence/manifest.ts +0 -64
  48. package/source/extensions.cadence/schemas.ts +0 -10
  49. package/source/extensions.cadence/types.ts +0 -41
  50. package/source/extensions.configuration/components.ts +0 -6
  51. package/source/extensions.configuration/const.ts +0 -30
  52. package/source/extensions.configuration/context.ts +0 -13
  53. package/source/extensions.configuration/deployment.ts +0 -159
  54. package/source/extensions.configuration/epoch.ts +0 -22
  55. package/source/extensions.configuration/index.ts +0 -10
  56. package/source/extensions.configuration/manifest.ts +0 -12
  57. package/source/extensions.configuration/schemas.ts +0 -9
  58. package/source/extensions.exposition/Annotation.ts +0 -91
  59. package/source/extensions.exposition/components.ts +0 -6
  60. package/source/extensions.exposition/const.ts +0 -45
  61. package/source/extensions.exposition/deployment.ts +0 -95
  62. package/source/extensions.exposition/index.ts +0 -16
  63. package/source/extensions.exposition/manifest.ts +0 -56
  64. package/source/extensions.exposition/schemas.ts +0 -16
  65. package/source/extensions.exposition/shortcuts.ts +0 -14
  66. package/source/extensions.exposition/syntax/index.ts +0 -2
  67. package/source/extensions.exposition/syntax/parse.ts +0 -171
  68. package/source/extensions.exposition/syntax/types.ts +0 -69
  69. package/source/extensions.fetch/context.ts +0 -10
  70. package/source/extensions.fetch/index.ts +0 -1
  71. package/source/extensions.introspection/annotation.ts +0 -87
  72. package/source/extensions.introspection/components.ts +0 -13
  73. package/source/extensions.introspection/const.ts +0 -46
  74. package/source/extensions.introspection/deployment.ts +0 -48
  75. package/source/extensions.introspection/index.ts +0 -6
  76. package/source/extensions.introspection/manifest.ts +0 -18
  77. package/source/extensions.introspection/schemas.ts +0 -12
  78. package/source/extensions.realtime/components.ts +0 -5
  79. package/source/extensions.realtime/deployment.ts +0 -89
  80. package/source/extensions.realtime/index.ts +0 -4
  81. package/source/extensions.stash/context.ts +0 -10
  82. package/source/extensions.stash/deployment.ts +0 -22
  83. package/source/extensions.stash/index.ts +0 -2
  84. package/source/extensions.state/context.ts +0 -9
  85. package/source/extensions.state/index.ts +0 -1
  86. package/source/extensions.storages/Annotation.ts +0 -57
  87. package/source/extensions.storages/context.ts +0 -14
  88. package/source/extensions.storages/deployment.ts +0 -91
  89. package/source/extensions.storages/index.ts +0 -9
  90. package/source/extensions.storages/manifest.ts +0 -7
  91. package/source/extensions.storages/schemas.ts +0 -15
  92. package/source/extensions.storages/secrets.ts +0 -22
  93. package/source/extensions.telemetry/const.ts +0 -6
  94. package/source/extensions.telemetry/context.ts +0 -11
  95. package/source/extensions.telemetry/deployment.ts +0 -91
  96. package/source/extensions.telemetry/index.ts +0 -5
  97. package/source/extensions.telemetry/ready.ts +0 -33
  98. package/source/index.ts +0 -2
  99. package/source/storages.mongodb/deployment.ts +0 -22
  100. package/source/storages.mongodb/index.ts +0 -1
  101. package/source/version.ts +0 -10
  102. package/transpiled/bindings.amqp/annotation.test.d.ts +0 -1
  103. package/transpiled/bindings.amqp/annotation.test.js +0 -36
  104. package/transpiled/bindings.amqp/annotation.test.js.map +0 -1
  105. package/transpiled/bindings.amqp/properties.test.d.ts +0 -1
  106. package/transpiled/bindings.amqp/properties.test.js +0 -7
  107. package/transpiled/bindings.amqp/properties.test.js.map +0 -1
  108. package/transpiled/bindings.loop/properties.test.d.ts +0 -1
  109. package/transpiled/bindings.loop/properties.test.js +0 -7
  110. package/transpiled/bindings.loop/properties.test.js.map +0 -1
  111. package/transpiled/bridges.node/exports.test.d.ts +0 -1
  112. package/transpiled/bridges.node/exports.test.js +0 -88
  113. package/transpiled/bridges.node/exports.test.js.map +0 -1
  114. package/transpiled/bridges.node/operations.test.d.ts +0 -1
  115. package/transpiled/bridges.node/operations.test.js +0 -108
  116. package/transpiled/bridges.node/operations.test.js.map +0 -1
  117. package/transpiled/extensions.cadence/manifest.test.d.ts +0 -1
  118. package/transpiled/extensions.cadence/manifest.test.js +0 -41
  119. package/transpiled/extensions.cadence/manifest.test.js.map +0 -1
  120. package/transpiled/extensions.configuration/deployment.test.d.ts +0 -1
  121. package/transpiled/extensions.configuration/deployment.test.js +0 -74
  122. package/transpiled/extensions.configuration/deployment.test.js.map +0 -1
  123. package/transpiled/extensions.configuration/manifest.test.d.ts +0 -1
  124. package/transpiled/extensions.configuration/manifest.test.js +0 -14
  125. package/transpiled/extensions.configuration/manifest.test.js.map +0 -1
  126. package/transpiled/extensions.exposition/manifest.test.d.ts +0 -1
  127. package/transpiled/extensions.exposition/manifest.test.js +0 -38
  128. package/transpiled/extensions.exposition/manifest.test.js.map +0 -1
  129. package/transpiled/extensions.exposition/schemas.test.d.ts +0 -1
  130. package/transpiled/extensions.exposition/schemas.test.js +0 -22
  131. package/transpiled/extensions.exposition/schemas.test.js.map +0 -1
  132. package/transpiled/extensions.exposition/syntax/parse.test.d.ts +0 -1
  133. package/transpiled/extensions.exposition/syntax/parse.test.js +0 -156
  134. package/transpiled/extensions.exposition/syntax/parse.test.js.map +0 -1
  135. package/transpiled/extensions.storages/schemas.test.d.ts +0 -1
  136. package/transpiled/extensions.storages/schemas.test.js +0 -59
  137. package/transpiled/extensions.storages/schemas.test.js.map +0 -1
  138. package/tsconfig.json +0 -10
@@ -1,10 +0,0 @@
1
- import type { Contribution } from '@toa.io/core/types'
2
-
3
- /** What this extension puts on the context of a component that declares it. */
4
- export function context(): Contribution {
5
- return {
6
- name: 'stash',
7
- type: 'Stash',
8
- imports: { '@toa.io/extensions.stash': ['Stash'] }
9
- }
10
- }
@@ -1,22 +0,0 @@
1
- import { createVariables, type URIMap, type Request } from '@toa.io/pointer'
2
- import type { context } from '@toa.io/norm'
3
- import type { Dependency } from '@toa.io/operations'
4
-
5
- export function deployment(
6
- instances: context.Dependency[],
7
- annotation: URIMap
8
- ): Dependency {
9
- const requests: Request[] = instances.map((instance) => createRequest(instance))
10
- const variables = createVariables(ID, annotation, requests)
11
-
12
- return { variables }
13
- }
14
-
15
- function createRequest(instance: context.Dependency): Request {
16
- return {
17
- group: instance.locator.label,
18
- selectors: [instance.locator.id]
19
- }
20
- }
21
-
22
- export const ID = 'stash'
@@ -1,2 +0,0 @@
1
- export { deployment, ID } from './deployment.js'
2
- export { context } from './context.js'
@@ -1,9 +0,0 @@
1
- import type { Contribution } from '@toa.io/core/types'
2
-
3
- /**
4
- * What this extension puts on the context of a component that declares it. What a component
5
- * keeps there is its own, and nothing declares it.
6
- */
7
- export function context(): Contribution {
8
- return { name: 'state', type: 'Record<string, any>' }
9
- }
@@ -1 +0,0 @@
1
- export { context } from './context.js'
@@ -1,57 +0,0 @@
1
- import assert from 'node:assert'
2
- import { secrets } from './secrets.js'
3
- import * as schemas from './schemas.js'
4
- import type { Provider } from './secrets.js'
5
- import type { Schema } from '@toa.io/schemas'
6
-
7
- export type Annotation = Record<string, Declaration>
8
-
9
- /** What a storage is declared as; what else it takes is the provider's, stated in its schema. */
10
- export type Declaration = { provider: Provider } & Record<string, any>
11
-
12
- export type { Provider }
13
-
14
- export function validateAnnotation(
15
- annotation: unknown
16
- ): asserts annotation is Annotation {
17
- try {
18
- schemas.annotation.validate(annotation)
19
- } catch (error) {
20
- explain(annotation)
21
-
22
- // if all declarations are valid, re-throw the error
23
- throw error
24
- }
25
- }
26
-
27
- /*
28
- It is required because `oneOf` schema is used for the annotation validation.
29
- */
30
- function explain(annotation: unknown): void {
31
- assert.ok(
32
- typeof annotation === 'object' && annotation !== null,
33
- 'TOA_STORAGES is not an object'
34
- )
35
-
36
- for (const declaration of Object.values(annotation)) {
37
- assert.ok(
38
- typeof declaration === 'object' &&
39
- declaration !== null &&
40
- declaration.provider in secrets,
41
- `Unknown provider '${declaration.provider}'`
42
- )
43
-
44
- assert.ok(
45
- declaration.provider in schemas,
46
- `No schema for provider '${declaration.provider}'`
47
- )
48
-
49
- const provider = declaration.provider as Provider
50
-
51
- // the declaration names the provider
52
- // oxlint-disable-next-line import/namespace
53
- const schema: Schema<Declaration> = schemas[provider]
54
-
55
- schema.validate(declaration, `Storage '${declaration.provider}' annotation`)
56
- }
57
- }
@@ -1,14 +0,0 @@
1
- import type { Contribution } from '@toa.io/core/types'
2
-
3
- /** What this extension puts on the context of a component that declares it. */
4
- export function context(declaration: string[]): Contribution | null {
5
- if (!Array.isArray(declaration) || declaration.length === 0) return null
6
-
7
- const names = declaration.map((name) => JSON.stringify(name)).join(' | ')
8
-
9
- return {
10
- name: 'storages',
11
- type: `Record<${names}, Storage>`,
12
- imports: { '@toa.io/extensions.storages': ['Storage'] }
13
- }
14
- }
@@ -1,91 +0,0 @@
1
- import * as assert from 'node:assert'
2
- import { secrets as declared } from './secrets.js'
3
- import { validateAnnotation } from './Annotation.js'
4
- import type { Annotation } from './Annotation.js'
5
- import type { Dependency, Variable, Mounts } from '@toa.io/operations'
6
- import type { context } from '@toa.io/norm'
7
-
8
- export const ENV_PREFIX = 'TOA_STORAGES'
9
-
10
- export function deployment(instances: Instance[], annotation: unknown): Dependency {
11
- validate(instances, annotation)
12
-
13
- const value = JSON.stringify(annotation)
14
- const pointer: Variable = { name: ENV_PREFIX, value }
15
- const secrets = getSecrets(annotation)
16
- const mounts = getMounts(instances, annotation)
17
-
18
- const dependency: Dependency = { variables: { global: [pointer, ...secrets] } }
19
-
20
- if (mounts !== null) dependency.mounts = mounts
21
-
22
- return dependency
23
- }
24
-
25
- function validate(
26
- instances: Instance[],
27
- annotation: unknown
28
- ): asserts annotation is Annotation {
29
- validateAnnotation(annotation)
30
-
31
- for (const instance of instances) {
32
- instance.manifest ??= []
33
-
34
- contains(instance, annotation)
35
- }
36
- }
37
-
38
- function contains(instance: Instance, annotation: Annotation): void {
39
- for (const name of instance.manifest)
40
- assert.ok(
41
- name in annotation,
42
- `Missing '${name}' storage annotation ` +
43
- `declared in '${instance.component.locator.id}'`
44
- )
45
- }
46
-
47
- function getSecrets(annotation: Annotation): Variable[] {
48
- const secrets: Variable[] = []
49
-
50
- for (const [name, declaration] of Object.entries(annotation)) {
51
- for (const secret of declared[declaration.provider])
52
- secrets.push({
53
- name: `${ENV_PREFIX}_${name}_${secret.name}`.toUpperCase(),
54
- secret: {
55
- name: `toa-storages-${name}`,
56
- key: secret.name,
57
- optional: secret.optional
58
- }
59
- })
60
- }
61
-
62
- return secrets
63
- }
64
-
65
- function getMounts(instances: Instance[], annotation: Annotation): Mounts | null {
66
- let mounts: Mounts | null = null
67
-
68
- for (const { locator, manifest } of instances)
69
- for (const name of manifest) {
70
- const declaration = annotation[name]
71
-
72
- // eslint-disable-next-line max-depth
73
- if (declaration.provider !== 'fs') continue
74
-
75
- // eslint-disable-next-line max-depth
76
- if (declaration.claim !== undefined) {
77
- mounts ??= {}
78
- mounts[locator.label] ??= []
79
-
80
- mounts[locator.label].push({
81
- name,
82
- path: declaration.path,
83
- claim: declaration.claim
84
- })
85
- }
86
- }
87
-
88
- return mounts
89
- }
90
-
91
- export type Instance = context.Dependency<string[]>
@@ -1,9 +0,0 @@
1
- export { deployment, ENV_PREFIX } from './deployment.js'
2
- export { manifest } from './manifest.js'
3
- export { validateAnnotation } from './Annotation.js'
4
- export { secrets } from './secrets.js'
5
- export { context } from './context.js'
6
- export * as schemas from './schemas.js'
7
-
8
- export type { Annotation, Declaration, Provider } from './Annotation.js'
9
- export type { Secret } from './secrets.js'
@@ -1,7 +0,0 @@
1
- export function manifest(manifest: string | string[] | null): string[] {
2
- if (manifest === null) return []
3
-
4
- if (typeof manifest === 'string') return [manifest]
5
-
6
- return manifest
7
- }
@@ -1,15 +0,0 @@
1
- import { resolve } from 'node:path'
2
- import { namespace } from '@toa.io/schemas'
3
- import type { Schema } from '@toa.io/schemas'
4
- import type { Annotation, Declaration } from './Annotation.js'
5
-
6
- const path = resolve(import.meta.dirname, '../../schemas/extensions.storages')
7
- const ns = namespace(path)
8
-
9
- export const annotation: Schema<Annotation> = ns.schema<Annotation>('annotation')
10
- export const s3: Schema<Declaration> = ns.schema<Declaration>('s3')
11
- export const spaces: Schema<Declaration> = ns.schema<Declaration>('spaces')
12
- export const cloudinary: Schema<Declaration> = ns.schema<Declaration>('cloudinary')
13
- export const fs: Schema<Declaration> = ns.schema<Declaration>('fs')
14
- export const tmp: Schema<Declaration> = ns.schema<Declaration>('tmp')
15
- export const test: Schema<Declaration> = ns.schema<Declaration>('test')
@@ -1,22 +0,0 @@
1
- /**
2
- * What each provider reads from the environment, stated apart from the provider so that a
3
- * deployment enumerates them without loading the SDK the provider is written against.
4
- */
5
- export const secrets: Record<Provider, readonly Secret[]> = {
6
- s3: [
7
- { name: 'ACCESS_KEY_ID', optional: true },
8
- { name: 'SECRET_ACCESS_KEY', optional: true }
9
- ],
10
- spaces: [{ name: 'ACCESS_KEY_ID' }, { name: 'SECRET_ACCESS_KEY' }],
11
- cloudinary: [{ name: 'API_KEY' }, { name: 'API_SECRET' }],
12
- fs: [],
13
- tmp: [],
14
- test: [{ name: 'USERNAME' }, { name: 'PASSWORD' }]
15
- }
16
-
17
- export type Provider = 's3' | 'spaces' | 'cloudinary' | 'fs' | 'tmp' | 'test'
18
-
19
- export interface Secret {
20
- readonly name: string
21
- readonly optional?: boolean
22
- }
@@ -1,6 +0,0 @@
1
- export const ID = 'telemetry'
2
-
3
- const ENV_PREFIX = 'TOA_TELEMETRY'
4
- export const LOGS_PREFIX = ENV_PREFIX + '_LOGS'
5
- export const TRACES_ENV = ENV_PREFIX + '_TRACES'
6
- export const READY_ENV = 'TOA_TELEMETRY_READY'
@@ -1,11 +0,0 @@
1
- import type { Contribution } from '@toa.io/core/types'
2
-
3
- /** What this extension puts on the context of every component, being declared for all. */
4
- export function context(): Contribution[] {
5
- const imports = { '@toa.io/extensions.telemetry': ['Logs', 'Span'] }
6
-
7
- return [
8
- { name: 'logs', type: 'Logs', imports },
9
- { name: 'span', type: 'Span', imports }
10
- ]
11
- }
@@ -1,91 +0,0 @@
1
- import assert from 'node:assert'
2
- import { LOGS_PREFIX, READY_ENV, TRACES_ENV } from './const.js'
3
- import { DEFAULT_ANNOTATION, normalizeAnnotation, type ReadyAnnotation } from './ready.js'
4
- import type { Dependency, Probe, Variables } from '@toa.io/operations'
5
- import type { ExportersConfig, LevelName } from 'openspan'
6
-
7
- export function deployment(_: unknown, annotation?: Annotation): Dependency {
8
- const variables: Variables = { global: [] }
9
-
10
- if (annotation?.logs !== undefined) addLogsVariables(annotation.logs, variables)
11
-
12
- if (annotation?.traces !== undefined) addTracesVariables(annotation.traces, variables)
13
-
14
- const ready = normalizeAnnotation(annotation?.ready)
15
-
16
- if (ready === false) {
17
- variables.global.push({ name: READY_ENV, value: JSON.stringify(false) })
18
-
19
- return { variables, probe: false }
20
- }
21
-
22
- variables.global.push({ name: READY_ENV, value: JSON.stringify(ready) })
23
-
24
- const probe: Probe = {
25
- path: ready.path ?? DEFAULT_ANNOTATION.path,
26
- port: ready.port ?? DEFAULT_ANNOTATION.port
27
- }
28
-
29
- return { variables, probe }
30
- }
31
-
32
- function addLogsVariables(annotation: LogsAnnotation, variables: Variables): void {
33
- const { level, ...components } = annotation
34
- const global = { level }
35
-
36
- if (level !== undefined)
37
- variables.global.push({ name: LOGS_PREFIX, value: JSON.stringify(global) })
38
-
39
- for (const [id, override] of Object.entries(components)) {
40
- const [namespace, name] = id.split('.')
41
- const value = Object.assign({}, global, override)
42
-
43
- variables.global.push({
44
- name: `${LOGS_PREFIX}_${namespace.toUpperCase()}_${name.toUpperCase()}`,
45
- value: JSON.stringify(value)
46
- })
47
- }
48
- }
49
-
50
- function addTracesVariables(annotation: TracesAnnotation, variables: Variables): void {
51
- const { sample, rate, exporters } = annotation
52
-
53
- if (sample !== undefined)
54
- assert.ok(
55
- typeof sample === 'number' && sample >= 0 && sample <= 1,
56
- 'telemetry.traces.sample must be a number within [0, 1]'
57
- )
58
-
59
- if (rate !== undefined)
60
- assert.ok(
61
- typeof rate === 'number' && rate > 0,
62
- 'telemetry.traces.rate must be a positive number'
63
- )
64
-
65
- if (exporters?.otlp !== undefined)
66
- assert.ok(
67
- typeof exporters.otlp.endpoint === 'string',
68
- 'telemetry.traces.exporters.otlp.endpoint is required'
69
- )
70
-
71
- variables.global.push({
72
- name: TRACES_ENV,
73
- value: JSON.stringify({ sample, rate, exporters })
74
- })
75
- }
76
-
77
- interface Annotation {
78
- logs?: LogsAnnotation & Record<string, LogsAnnotation>
79
- traces?: TracesAnnotation
80
- ready?: ReadyAnnotation
81
- }
82
-
83
- interface LogsAnnotation {
84
- level: LevelName
85
- }
86
-
87
- interface TracesAnnotation {
88
- sample?: number
89
- rate?: number
90
- exporters?: ExportersConfig
91
- }
@@ -1,5 +0,0 @@
1
- export { deployment } from './deployment.js'
2
- export { ID, LOGS_PREFIX, TRACES_ENV, READY_ENV } from './const.js'
3
- export { DEFAULT_ANNOTATION, normalizeAnnotation } from './ready.js'
4
- export type { ReadyAnnotation, ReadyConfig } from './ready.js'
5
- export { context } from './context.js'
@@ -1,33 +0,0 @@
1
- export function normalizeAnnotation(
2
- ready: ReadyAnnotation | undefined
3
- ): ReadyConfig | false {
4
- if (ready === false) return false
5
-
6
- if (ready === undefined) return { enabled: true, ...DEFAULT_ANNOTATION }
7
-
8
- return {
9
- enabled: true,
10
- path: ready.path ?? DEFAULT_ANNOTATION.path,
11
- port: ready.port ?? DEFAULT_ANNOTATION.port
12
- }
13
- }
14
-
15
- export const DEFAULT_ANNOTATION = {
16
- path: '/.ready',
17
- port: 8001
18
- } as const
19
-
20
- export type ReadyAnnotation =
21
- | false
22
- | {
23
- path?: string
24
- port?: number
25
- }
26
-
27
- export type ReadyConfig =
28
- | false
29
- | {
30
- enabled?: boolean
31
- path?: string
32
- port?: number
33
- }
package/source/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { version } from './version.js'
2
- export { definition, DEFINED } from './definition.js'
@@ -1,22 +0,0 @@
1
- import { createVariables, type Request, type URIMap } from '@toa.io/pointer'
2
- import type { context } from '@toa.io/norm'
3
- import type { Dependency } from '@toa.io/operations'
4
-
5
- export function deployment(
6
- instances: context.Dependency[],
7
- annotation: URIMap
8
- ): Dependency {
9
- const requests = instances.map((instance) => createRequest(instance))
10
- const variables = createVariables(ID, annotation, requests)
11
-
12
- return { variables }
13
- }
14
-
15
- function createRequest(instance: context.Dependency): Request {
16
- return {
17
- group: instance.locator.label,
18
- selectors: [instance.locator.id]
19
- }
20
- }
21
-
22
- export const ID = 'mongodb'
@@ -1 +0,0 @@
1
- export { deployment, ID } from './deployment.js'
package/source/version.ts DELETED
@@ -1,10 +0,0 @@
1
- import { readFileSync } from 'node:fs'
2
- import { join } from 'node:path'
3
-
4
- /**
5
- * The version of Toa. This package is versioned with every release, so its version
6
- * is the runtime's, whether or not the runtime is installed beside it.
7
- */
8
- export const version: string = JSON.parse(
9
- readFileSync(join(import.meta.dirname, '../package.json'), 'utf8')
10
- ).version
@@ -1 +0,0 @@
1
- export {};
@@ -1,36 +0,0 @@
1
- import { it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { generate } from 'randomstring';
4
- import { normalize } from './annotation.js';
5
- it('should expand string', async () => {
6
- const declaration = uri();
7
- const annotation = normalize(declaration);
8
- assert.partialDeepStrictEqual(annotation, {
9
- context: {
10
- '.': [declaration]
11
- }
12
- });
13
- });
14
- it('should expand context default', async () => {
15
- const declaration = { context: uri() };
16
- const annotation = normalize(declaration);
17
- assert.partialDeepStrictEqual(annotation, {
18
- context: {
19
- '.': [declaration.context]
20
- }
21
- });
22
- });
23
- it('should expand context with sources', async () => {
24
- const declaration = { context: uri(), sources: { foo: [uri()] } };
25
- const annotation = normalize(declaration);
26
- assert.partialDeepStrictEqual(annotation, {
27
- context: {
28
- '.': [declaration.context]
29
- },
30
- sources: declaration.sources
31
- });
32
- });
33
- function uri() {
34
- return 'http://host-' + generate();
35
- }
36
- //# sourceMappingURL=annotation.test.js.map
@@ -1 +0,0 @@
1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O,CAAC;SAC3B;QACD,OAAO,EAAE,WAAW,CAAC,OAAO;KAC7B,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,SAAS,GAAG;IACV,OAAO,cAAc,GAAG,QAAQ,EAAE,CAAA;AACpC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import { it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { properties } from './index.js';
4
- it('is asynchronous', () => {
5
- assert.deepStrictEqual(properties, { async: true });
6
- });
7
- //# sourceMappingURL=properties.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"properties.test.js","sourceRoot":"","sources":["../../source/bindings.amqp/properties.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAC9B,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,EAAE,CAAC,iBAAiB,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACrD,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import { it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { properties } from './index.js';
4
- it('is synchronous and local', () => {
5
- assert.deepStrictEqual(properties, { async: false, local: true });
6
- });
7
- //# sourceMappingURL=properties.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"properties.test.js","sourceRoot":"","sources":["../../source/bindings.loop/properties.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAC9B,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;IAClC,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACnE,CAAC,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,88 +0,0 @@
1
- import { describe, it } from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import { exports } from './exports.js';
4
- const read = (text, file = 'module.js') => exports(file, text);
5
- describe('ES modules', () => {
6
- it('reads a declaration exported where it is written', () => {
7
- const bound = read('export async function transition(input, object, context) {}');
8
- assert.deepStrictEqual(bound.get('transition'), {
9
- kind: 'function',
10
- declared: 'transition',
11
- params: ['input', 'object', 'context']
12
- });
13
- });
14
- it('reads a specifier by the name it is exported as', () => {
15
- const bound = read('const meter = (input) => input\nexport { meter as computation }');
16
- assert.deepStrictEqual(bound.get('computation'), {
17
- kind: 'function',
18
- declared: undefined,
19
- params: ['input']
20
- });
21
- });
22
- it('reads a default export with the name it declares', () => {
23
- const bound = read('export default function transition(_, changeset) {}');
24
- assert.deepStrictEqual(bound.get('default'), {
25
- kind: 'function',
26
- declared: 'transition',
27
- params: ['_', 'changeset']
28
- });
29
- });
30
- it('reads a class with its methods', () => {
31
- const bound = read('export class Transition {\n execute(input, object) {}\n run() {}\n}');
32
- assert.deepStrictEqual(bound.get('Transition'), {
33
- kind: 'class',
34
- declared: 'Transition',
35
- methods: { execute: ['input', 'object'], run: [] }
36
- });
37
- });
38
- it('reads what is not written as a function or a class as other', () => {
39
- const bound = read('export const computation = wrap(fn)\nexport const NAME = "x"');
40
- assert.deepStrictEqual(bound.get('computation'), { kind: 'other' });
41
- assert.deepStrictEqual(bound.get('NAME'), { kind: 'other' });
42
- });
43
- it('leaves a type export out', () => {
44
- const bound = read('export type Foo = string\nexport interface Bar {}', 'module.ts');
45
- assert.equal(bound.size, 0);
46
- });
47
- it('names no parameter that is a pattern or a rest', () => {
48
- const bound = read('export function computation({ a }, ...rest) {}');
49
- assert.deepStrictEqual(bound.get('computation')?.params, [undefined, undefined]);
50
- });
51
- it('names a parameter with a default', () => {
52
- const bound = read('export const effect = (input, stream = null) => stream');
53
- assert.deepStrictEqual(bound.get('effect')?.params, ['input', 'stream']);
54
- });
55
- });
56
- describe('TypeScript', () => {
57
- it('reads through annotations', () => {
58
- const bound = read('export async function transition(input: string, object: State): Promise<Reply> {}', 'module.ts');
59
- assert.deepStrictEqual(bound.get('transition')?.params, ['input', 'object']);
60
- });
61
- it('reads a class with private fields and typed methods', () => {
62
- const bound = read('export class Computation {\n #foo: string = ""\n async mount(context: Context): Promise<void> {}\n async execute(input: string): Promise<string> { return input }\n}', 'module.ts');
63
- assert.deepStrictEqual(bound.get('Computation')?.methods, {
64
- mount: ['context'],
65
- execute: ['input']
66
- });
67
- });
68
- it('names the file that does not parse', () => {
69
- assert.throws(() => read('export function (', 'broken.js'), /broken\.js/);
70
- });
71
- });
72
- describe('CommonJS', () => {
73
- it('reads module.exports', () => {
74
- const bound = read('function computation(input) {}\nmodule.exports = { computation, other: () => 1 }', 'module.cjs');
75
- assert.deepStrictEqual(bound.get('computation'), {
76
- kind: 'function',
77
- declared: 'computation',
78
- params: ['input']
79
- });
80
- assert.deepStrictEqual(bound.get('other'), { kind: 'function', declared: undefined, params: [] });
81
- });
82
- it('reads exports.name and module.exports.name', () => {
83
- const bound = read('exports.transition = function (input, object) {}\nmodule.exports.condition = () => true', 'module.cjs');
84
- assert.deepStrictEqual(bound.get('transition')?.params, ['input', 'object']);
85
- assert.equal(bound.get('condition')?.kind, 'function');
86
- });
87
- });
88
- //# sourceMappingURL=exports.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports.test.js","sourceRoot":"","sources":["../../source/bridges.node/exports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,IAAI,GA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