@toa.io/definitions 1.0.0-alpha.288 → 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 (141) hide show
  1. package/LICENSE +22 -0
  2. package/digest/extensions.configuration.json +1 -1
  3. package/digest/extensions.exposition.json +1 -1
  4. package/digest/extensions.introspection.json +1 -1
  5. package/digest/extensions.realtime.json +1 -1
  6. package/package.json +27 -9
  7. package/readme.md +1 -0
  8. package/transpiled/bridges.node/exports.js +25 -2
  9. package/transpiled/bridges.node/exports.js.map +1 -1
  10. package/transpiled/digest/generate.js +23 -3
  11. package/transpiled/digest/generate.js.map +1 -1
  12. package/transpiled/digest/read.d.ts +8 -0
  13. package/transpiled/digest/read.js +11 -0
  14. package/transpiled/digest/read.js.map +1 -1
  15. package/transpiled/extensions.exposition/index.d.ts +1 -0
  16. package/transpiled/extensions.exposition/index.js +1 -0
  17. package/transpiled/extensions.exposition/index.js.map +1 -1
  18. package/transpiled/extensions.exposition/packages.d.ts +11 -0
  19. package/transpiled/extensions.exposition/packages.js +17 -0
  20. package/transpiled/extensions.exposition/packages.js.map +1 -0
  21. package/transpiled/extensions.storages/index.d.ts +1 -0
  22. package/transpiled/extensions.storages/index.js +1 -0
  23. package/transpiled/extensions.storages/index.js.map +1 -1
  24. package/transpiled/extensions.storages/packages.d.ts +19 -0
  25. package/transpiled/extensions.storages/packages.js +41 -0
  26. package/transpiled/extensions.storages/packages.js.map +1 -0
  27. package/source/bindings.amqp/annotation.ts +0 -26
  28. package/source/bindings.amqp/context.ts +0 -68
  29. package/source/bindings.amqp/deployment.ts +0 -14
  30. package/source/bindings.amqp/index.ts +0 -9
  31. package/source/bindings.amqp/instance.ts +0 -3
  32. package/source/bindings.amqp/sources.ts +0 -39
  33. package/source/bindings.loop/index.ts +0 -3
  34. package/source/bridges.bash/const.ts +0 -2
  35. package/source/bridges.bash/define.ts +0 -38
  36. package/source/bridges.bash/index.ts +0 -2
  37. package/source/bridges.node/define.ts +0 -69
  38. package/source/bridges.node/exports.ts +0 -175
  39. package/source/bridges.node/index.ts +0 -6
  40. package/source/bridges.node/operations.ts +0 -127
  41. package/source/bridges.node/sources.ts +0 -44
  42. package/source/definition.ts +0 -38
  43. package/source/digest/generate.ts +0 -77
  44. package/source/digest/read.ts +0 -39
  45. package/source/extensions.cadence/components.ts +0 -6
  46. package/source/extensions.cadence/const.ts +0 -31
  47. package/source/extensions.cadence/context.ts +0 -10
  48. package/source/extensions.cadence/deployment.ts +0 -37
  49. package/source/extensions.cadence/index.ts +0 -8
  50. package/source/extensions.cadence/manifest.ts +0 -64
  51. package/source/extensions.cadence/schemas.ts +0 -10
  52. package/source/extensions.cadence/types.ts +0 -41
  53. package/source/extensions.configuration/components.ts +0 -6
  54. package/source/extensions.configuration/const.ts +0 -30
  55. package/source/extensions.configuration/context.ts +0 -13
  56. package/source/extensions.configuration/deployment.ts +0 -159
  57. package/source/extensions.configuration/epoch.ts +0 -22
  58. package/source/extensions.configuration/index.ts +0 -10
  59. package/source/extensions.configuration/manifest.ts +0 -12
  60. package/source/extensions.configuration/schemas.ts +0 -9
  61. package/source/extensions.exposition/Annotation.ts +0 -91
  62. package/source/extensions.exposition/components.ts +0 -6
  63. package/source/extensions.exposition/const.ts +0 -45
  64. package/source/extensions.exposition/deployment.ts +0 -95
  65. package/source/extensions.exposition/index.ts +0 -16
  66. package/source/extensions.exposition/manifest.ts +0 -56
  67. package/source/extensions.exposition/schemas.ts +0 -16
  68. package/source/extensions.exposition/shortcuts.ts +0 -14
  69. package/source/extensions.exposition/syntax/index.ts +0 -2
  70. package/source/extensions.exposition/syntax/parse.ts +0 -171
  71. package/source/extensions.exposition/syntax/types.ts +0 -69
  72. package/source/extensions.fetch/context.ts +0 -10
  73. package/source/extensions.fetch/index.ts +0 -1
  74. package/source/extensions.introspection/annotation.ts +0 -87
  75. package/source/extensions.introspection/components.ts +0 -13
  76. package/source/extensions.introspection/const.ts +0 -46
  77. package/source/extensions.introspection/deployment.ts +0 -48
  78. package/source/extensions.introspection/index.ts +0 -6
  79. package/source/extensions.introspection/manifest.ts +0 -18
  80. package/source/extensions.introspection/schemas.ts +0 -12
  81. package/source/extensions.realtime/components.ts +0 -5
  82. package/source/extensions.realtime/deployment.ts +0 -89
  83. package/source/extensions.realtime/index.ts +0 -4
  84. package/source/extensions.stash/context.ts +0 -10
  85. package/source/extensions.stash/deployment.ts +0 -22
  86. package/source/extensions.stash/index.ts +0 -2
  87. package/source/extensions.state/context.ts +0 -9
  88. package/source/extensions.state/index.ts +0 -1
  89. package/source/extensions.storages/Annotation.ts +0 -57
  90. package/source/extensions.storages/context.ts +0 -14
  91. package/source/extensions.storages/deployment.ts +0 -91
  92. package/source/extensions.storages/index.ts +0 -9
  93. package/source/extensions.storages/manifest.ts +0 -7
  94. package/source/extensions.storages/schemas.ts +0 -15
  95. package/source/extensions.storages/secrets.ts +0 -22
  96. package/source/extensions.telemetry/const.ts +0 -6
  97. package/source/extensions.telemetry/context.ts +0 -11
  98. package/source/extensions.telemetry/deployment.ts +0 -91
  99. package/source/extensions.telemetry/index.ts +0 -5
  100. package/source/extensions.telemetry/ready.ts +0 -33
  101. package/source/index.ts +0 -2
  102. package/source/storages.mongodb/deployment.ts +0 -22
  103. package/source/storages.mongodb/index.ts +0 -1
  104. package/source/version.ts +0 -10
  105. package/transpiled/bindings.amqp/annotation.test.d.ts +0 -1
  106. package/transpiled/bindings.amqp/annotation.test.js +0 -36
  107. package/transpiled/bindings.amqp/annotation.test.js.map +0 -1
  108. package/transpiled/bindings.amqp/properties.test.d.ts +0 -1
  109. package/transpiled/bindings.amqp/properties.test.js +0 -7
  110. package/transpiled/bindings.amqp/properties.test.js.map +0 -1
  111. package/transpiled/bindings.loop/properties.test.d.ts +0 -1
  112. package/transpiled/bindings.loop/properties.test.js +0 -7
  113. package/transpiled/bindings.loop/properties.test.js.map +0 -1
  114. package/transpiled/bridges.node/exports.test.d.ts +0 -1
  115. package/transpiled/bridges.node/exports.test.js +0 -88
  116. package/transpiled/bridges.node/exports.test.js.map +0 -1
  117. package/transpiled/bridges.node/operations.test.d.ts +0 -1
  118. package/transpiled/bridges.node/operations.test.js +0 -108
  119. package/transpiled/bridges.node/operations.test.js.map +0 -1
  120. package/transpiled/extensions.cadence/manifest.test.d.ts +0 -1
  121. package/transpiled/extensions.cadence/manifest.test.js +0 -41
  122. package/transpiled/extensions.cadence/manifest.test.js.map +0 -1
  123. package/transpiled/extensions.configuration/deployment.test.d.ts +0 -1
  124. package/transpiled/extensions.configuration/deployment.test.js +0 -74
  125. package/transpiled/extensions.configuration/deployment.test.js.map +0 -1
  126. package/transpiled/extensions.configuration/manifest.test.d.ts +0 -1
  127. package/transpiled/extensions.configuration/manifest.test.js +0 -14
  128. package/transpiled/extensions.configuration/manifest.test.js.map +0 -1
  129. package/transpiled/extensions.exposition/manifest.test.d.ts +0 -1
  130. package/transpiled/extensions.exposition/manifest.test.js +0 -38
  131. package/transpiled/extensions.exposition/manifest.test.js.map +0 -1
  132. package/transpiled/extensions.exposition/schemas.test.d.ts +0 -1
  133. package/transpiled/extensions.exposition/schemas.test.js +0 -22
  134. package/transpiled/extensions.exposition/schemas.test.js.map +0 -1
  135. package/transpiled/extensions.exposition/syntax/parse.test.d.ts +0 -1
  136. package/transpiled/extensions.exposition/syntax/parse.test.js +0 -156
  137. package/transpiled/extensions.exposition/syntax/parse.test.js.map +0 -1
  138. package/transpiled/extensions.storages/schemas.test.d.ts +0 -1
  139. package/transpiled/extensions.storages/schemas.test.js +0 -59
  140. package/transpiled/extensions.storages/schemas.test.js.map +0 -1
  141. package/tsconfig.json +0 -10
@@ -1,12 +0,0 @@
1
- import { resolve } from 'node:path'
2
- import * as schemas 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.introspection')
7
- const namespace = schemas.namespace(path)
8
-
9
- export const annotation: Schema<Exclude<Annotation, false>> =
10
- namespace.schema('annotation')
11
- export const declaration: Schema<Exclude<Declaration, false>> =
12
- namespace.schema('declaration')
@@ -1,5 +0,0 @@
1
- import { components as digest, type Components } from '../digest/read.js'
2
-
3
- export function components(): Components {
4
- return digest('extensions.realtime')
5
- }
@@ -1,89 +0,0 @@
1
- import { components } from './components.js'
2
- import { version } from '../version.js'
3
- import type { Dependency, Instances, Resources, Service } from '@toa.io/operations'
4
-
5
- /** Where Toa's release publishes this service's image. An application takes it
6
- * instead of building one when its context says `registry.services: published`. */
7
- export const image = 'ghcr.io/toa-io/extension-realtime-streams'
8
-
9
- export const standalone = true
10
-
11
- export function deployment(
12
- instances: Instances<Declaration>,
13
- annotation?: Declaration & Annotation
14
- ): Dependency {
15
- const routes = []
16
- const { resources, ...annotatedRoutes } = annotation ?? {}
17
- const labels = components().labels
18
-
19
- if (annotatedRoutes !== undefined) routes.push(...parse(annotatedRoutes))
20
-
21
- for (const instance of instances) {
22
- const completed: Declaration = {}
23
-
24
- for (const [key, value] of Object.entries(instance.manifest)) {
25
- const event = instance.locator.id + '.' + key
26
-
27
- completed[event] = value
28
- }
29
-
30
- routes.push(...parse(completed))
31
- }
32
-
33
- const service: Service = {
34
- group: 'realtime',
35
- name: 'streams',
36
- image,
37
- version,
38
- components: labels,
39
- resources,
40
- variables: [
41
- {
42
- name: 'TOA_REALTIME',
43
- value: JSON.stringify(routes)
44
- }
45
- ]
46
- }
47
-
48
- return { services: [service], events: routes.map((route) => route.event) }
49
- }
50
-
51
- export function parse(declaration: Declaration): Route[] {
52
- const routes: Route[] = []
53
-
54
- for (const [event, value] of Object.entries(declaration))
55
- if (isObject(value)) {
56
- const properties = Array.isArray(value.key) ? value.key : [value.key]
57
-
58
- routes.push({ event, properties, expose: value.expose })
59
- } else {
60
- const properties = Array.isArray(value) ? value : [value]
61
-
62
- routes.push({ event, properties })
63
- }
64
-
65
- return routes
66
- }
67
-
68
- function isObject(value: Entry): value is RouteDeclaration {
69
- return typeof value === 'object' && !Array.isArray(value)
70
- }
71
-
72
- export type Entry = string | string[] | RouteDeclaration
73
-
74
- export type Declaration = Record<string, Entry>
75
-
76
- export interface RouteDeclaration {
77
- key: string | string[]
78
- expose?: string[]
79
- }
80
-
81
- export interface Route {
82
- event: string
83
- properties: string[]
84
- expose?: string[]
85
- }
86
-
87
- interface Annotation {
88
- resources?: Resources
89
- }
@@ -1,4 +0,0 @@
1
- export { deployment, image, standalone, parse } from './deployment.js'
2
- export { components } from './components.js'
3
-
4
- export type { Declaration, Entry, Route, RouteDeclaration } from './deployment.js'
@@ -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
- {"version":3,"file":"annotation.test.js","sourceRoot":"","sources":["../../source/bindings.amqp/annotation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAC9B,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAA;IACzB,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;IAEzC,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE;QACxC,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,WAAW,CAAC;SACnB;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;IAC7C,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,CAAA;IACtC,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;IAEzC,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE;QACxC,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;SAC3B;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;IAClD,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAA;IACjE,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,CAAA;IAEzC,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE;QACxC,OAAO,EAAE;YACP,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,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 {};