@toa.io/definitions 1.0.0-alpha.331 → 1.0.0-alpha.333

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 (40) hide show
  1. package/digest/extensions.chronicles.json +1 -0
  2. package/digest/extensions.exposition.json +1 -1
  3. package/package.json +12 -12
  4. package/schemas/extensions.chronicles/annotation.cos.yaml +52 -0
  5. package/schemas/extensions.chronicles/declaration.cos.yaml +60 -0
  6. package/schemas/extensions.exposition/annotation.cos.yaml +10 -17
  7. package/transpiled/definition.js +1 -0
  8. package/transpiled/definition.js.map +1 -1
  9. package/transpiled/digest/generate.js +1 -0
  10. package/transpiled/digest/generate.js.map +1 -1
  11. package/transpiled/extensions.chronicles/components.d.ts +7 -0
  12. package/transpiled/extensions.chronicles/components.js +10 -0
  13. package/transpiled/extensions.chronicles/components.js.map +1 -0
  14. package/transpiled/extensions.chronicles/const.d.ts +20 -0
  15. package/transpiled/extensions.chronicles/const.js +26 -0
  16. package/transpiled/extensions.chronicles/const.js.map +1 -0
  17. package/transpiled/extensions.chronicles/context.d.ts +3 -0
  18. package/transpiled/extensions.chronicles/context.js +11 -0
  19. package/transpiled/extensions.chronicles/context.js.map +1 -0
  20. package/transpiled/extensions.chronicles/contract.d.ts +7 -0
  21. package/transpiled/extensions.chronicles/contract.js +69 -0
  22. package/transpiled/extensions.chronicles/contract.js.map +1 -0
  23. package/transpiled/extensions.chronicles/deployment.d.ts +12 -0
  24. package/transpiled/extensions.chronicles/deployment.js +84 -0
  25. package/transpiled/extensions.chronicles/deployment.js.map +1 -0
  26. package/transpiled/extensions.chronicles/index.d.ts +7 -0
  27. package/transpiled/extensions.chronicles/index.js +7 -0
  28. package/transpiled/extensions.chronicles/index.js.map +1 -0
  29. package/transpiled/extensions.chronicles/manifest.d.ts +12 -0
  30. package/transpiled/extensions.chronicles/manifest.js +63 -0
  31. package/transpiled/extensions.chronicles/manifest.js.map +1 -0
  32. package/transpiled/extensions.chronicles/schemas.d.ts +4 -0
  33. package/transpiled/extensions.chronicles/schemas.js +7 -0
  34. package/transpiled/extensions.chronicles/schemas.js.map +1 -0
  35. package/transpiled/extensions.chronicles/types.d.ts +81 -0
  36. package/transpiled/extensions.chronicles/types.js +2 -0
  37. package/transpiled/extensions.chronicles/types.js.map +1 -0
  38. package/transpiled/extensions.exposition/Annotation.d.ts +5 -7
  39. package/transpiled/extensions.exposition/deployment.js +8 -0
  40. package/transpiled/extensions.exposition/deployment.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toa.io/definitions",
3
- "version": "1.0.0-alpha.331",
3
+ "version": "1.0.0-alpha.333",
4
4
  "type": "module",
5
5
  "description": "What Toa packages declare, read without running them",
6
6
  "author": "temich <tema.gurtovoy@gmail.com>",
@@ -30,9 +30,9 @@
30
30
  "!**/.env*"
31
31
  ],
32
32
  "dependencies": {
33
- "@toa.io/generic": "1.0.0-alpha.330",
34
- "@toa.io/pointer": "1.0.0-alpha.330",
35
- "@toa.io/schemas": "1.0.0-alpha.330",
33
+ "@toa.io/generic": "1.0.0-alpha.332",
34
+ "@toa.io/pointer": "1.0.0-alpha.332",
35
+ "@toa.io/schemas": "1.0.0-alpha.332",
36
36
  "croner": "10.0.1"
37
37
  },
38
38
  "scripts": {
@@ -45,18 +45,18 @@
45
45
  "./*": "./transpiled/*/index.js"
46
46
  },
47
47
  "devDependencies": {
48
- "@aws-sdk/client-s3": "3.1148.0",
49
- "@aws-sdk/lib-storage": "3.1148.0",
50
- "@toa.io/core": "1.0.0-alpha.330",
48
+ "@aws-sdk/client-s3": "3.1156.0",
49
+ "@aws-sdk/lib-storage": "3.1156.0",
50
+ "@toa.io/core": "1.0.0-alpha.333",
51
51
  "cloudinary": "2.11.0",
52
52
  "openspan": "1.0.0-alpha.330",
53
- "oxc-parser": "0.153.0"
53
+ "oxc-parser": "0.155.0"
54
54
  },
55
55
  "peerDependencies": {
56
- "@aws-sdk/client-s3": "3.1148.0",
57
- "@aws-sdk/lib-storage": "3.1148.0",
56
+ "@aws-sdk/client-s3": "3.1156.0",
57
+ "@aws-sdk/lib-storage": "3.1156.0",
58
58
  "cloudinary": "2.11.0",
59
- "oxc-parser": "0.153.0"
59
+ "oxc-parser": "0.155.0"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "@aws-sdk/client-s3": {
@@ -72,5 +72,5 @@
72
72
  "optional": true
73
73
  }
74
74
  },
75
- "gitHead": "e7020d160910ca4f0c2ff9040b3cbb4fca8ea41f"
75
+ "gitHead": "ddb74b2f99026fae540a8a8e0a49c26cbd22886a"
76
76
  }
@@ -0,0 +1,52 @@
1
+ # context.toa.yaml chronicles annotation
2
+ type: object
3
+ properties:
4
+ broker:
5
+ description: The AMQP address of the broker the rows are published to
6
+ type: string
7
+ pattern: ^amqps?://
8
+ store:
9
+ description: Where the log is read, by the provider that keeps it
10
+ oneOf:
11
+ - type: object
12
+ properties:
13
+ provider:
14
+ const: clickhouse
15
+ url:
16
+ description: The HTTP address of ClickHouse; what is read is the user's own
17
+ type: string
18
+ format: uri
19
+ required: [provider, url]
20
+ additionalProperties: false
21
+ retention:
22
+ description: Days a row of `events` and of `encounters` is kept; absent, kept
23
+ type: integer
24
+ minimum: 1
25
+ encounters:
26
+ description: Whether the routes clients send encounters to are served
27
+ type: boolean
28
+ ip:
29
+ description: >
30
+ How much of a client's address the log keeps: its network, truncated to /24 of IPv4 and /48
31
+ of IPv6, or all of it
32
+ enum: [truncated, full]
33
+ resources:
34
+ # what the service may take; `null` deploys it without any, which every deployment has to
35
+ # state one way or the other — see `migrations/262.md`
36
+ type: object
37
+ nullable: true
38
+ properties:
39
+ cpu:
40
+ type: array
41
+ items:
42
+ type: string
43
+ minItems: 2
44
+ maxItems: 2
45
+ memory:
46
+ type: array
47
+ items:
48
+ type: string
49
+ minItems: 2
50
+ maxItems: 2
51
+ required: [broker, store]
52
+ additionalProperties: false
@@ -0,0 +1,60 @@
1
+ # manifest.toa.yaml chronicles declaration, normalised: the events whose renderings are rows of
2
+ # the log, the event whose payload is the entity as it stands, and the facts the component sends,
3
+ # each with its contract. What a contract's properties are is checked by the extension, which
4
+ # says where a property is that has no type of the log.
5
+ type: object
6
+ properties:
7
+ events:
8
+ type: object
9
+ propertyNames:
10
+ pattern: ^[a-zA-Z][a-zA-Z0-9]*$
11
+ additionalProperties:
12
+ $ref: '#/definitions/contract'
13
+ state:
14
+ type: object
15
+ properties:
16
+ event:
17
+ description: The event whose payload is the entity as it stands
18
+ type: string
19
+ pattern: ^[a-zA-Z][a-zA-Z0-9]*$
20
+ description:
21
+ $ref: '#/definitions/description'
22
+ properties:
23
+ $ref: '#/definitions/properties'
24
+ required: [event, description, properties]
25
+ additionalProperties: false
26
+ facts:
27
+ type: object
28
+ propertyNames:
29
+ pattern: ^[a-zA-Z][a-zA-Z0-9]*(\.[a-zA-Z][a-zA-Z0-9]*)*$
30
+ additionalProperties:
31
+ $ref: '#/definitions/contract'
32
+ identity:
33
+ description: The property of the payloads that names the identity a row is of; null, none
34
+ type: [string, "null"]
35
+ pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
36
+ timestamp:
37
+ description: >
38
+ The property of the payloads that says when the change was made, in milliseconds; null, none,
39
+ and the time the message carries is when
40
+ type: [string, "null"]
41
+ pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
42
+ required: [events, facts, timestamp]
43
+ additionalProperties: false
44
+ definitions:
45
+ contract:
46
+ type: object
47
+ properties:
48
+ description:
49
+ $ref: '#/definitions/description'
50
+ properties:
51
+ $ref: '#/definitions/properties'
52
+ required: [description, properties]
53
+ additionalProperties: false
54
+ description:
55
+ description: What the label means
56
+ type: string
57
+ minLength: 1
58
+ properties:
59
+ description: What of the payload is written, as JSON Schema
60
+ type: object
@@ -47,24 +47,17 @@ properties:
47
47
  type: integer
48
48
  minimum: 1
49
49
  additionalProperties: false
50
+ country:
51
+ description: The header the client's country is read from, which the edge in front writes
52
+ type: string
53
+ minLength: 1
50
54
  censor:
51
- description: Header values a request is answered 451 for
52
- type: object
53
- properties:
54
- header:
55
- description: The request header the values are read from, in any case
56
- type: string
57
- minLength: 1
58
- values:
59
- description: What the header holds for a request to be refused, compared exactly
60
- type: array
61
- items:
62
- type: string
63
- minItems: 1
64
- required:
65
- - header
66
- - values
67
- additionalProperties: false
55
+ description: The countries a request is answered 451 from, as the header `country` names holds them
56
+ type: array
57
+ items:
58
+ type: string
59
+ minLength: 1
60
+ minItems: 1
68
61
  protocol:
69
62
  type: string
70
63
  enum: [h1, h2c]
@@ -36,6 +36,7 @@ export const DEFINED = new Set([
36
36
  'bridges.bash',
37
37
  'bridges.node',
38
38
  'extensions.cadence',
39
+ 'extensions.chronicles',
39
40
  'extensions.configuration',
40
41
  'extensions.continuity',
41
42
  'extensions.convergence',
@@ -1 +1 @@
1
- {"version":3,"file":"definition.js","sourceRoot":"","sources":["../source/definition.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAiB;IAChD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAElD,sFAAsF;IACtF,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE9D,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1C,KAAK,CAAC,MAAM,CAAC,KAAK,MAAM,kCAAC,KAAK,MAAM,WAAW,EAAC,CAAA;IAEhD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAA;IAElC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAEpC,MAAM,KAAK,GAAI,MAA4C,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IAEvE,IAAI,KAA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AAC,CAAA;IAEvE,IAAI,KAAK,KAAK,SAAS;QACrB,MAAM,IAAI,KAAK,CAAC,IAAI,SAAS,uBAAuB,KAAK,GAAG,MAAM,kBAAkB,CAAC,CAAA;IAEvF,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,KAAK,GAAoC,EAAE,CAAA;AAEjD,MAAM,KAAK,GAAG,UAAU,CAAA;AAExB,wFAAwF;AACxF,MAAM,CAAC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC;IAClD,eAAe;IACf,eAAe;IACf,eAAe;IACf,cAAc;IACd,cAAc;IACd,oBAAoB;IACpB,uBAAuB;IACvB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,uBAAuB;IACvB,kBAAkB;IAClB,0BAA0B;IAC1B,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,sBAAsB;IACtB,kBAAkB;CACnB,CAAC,CAAA"}
@@ -13,6 +13,7 @@ const require = createRequire(import.meta.url);
13
13
  const { component } = (await import('@toa.io/norm'));
14
14
  const DIGESTED = [
15
15
  'extensions.cadence',
16
+ 'extensions.chronicles',
16
17
  'extensions.configuration',
17
18
  'extensions.continuity',
18
19
  'extensions.exposition',
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../source/digest/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAGzF;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C,8CAA8C;AAC9C,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,MAAM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AK,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,KAAK;QACnC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,UAAU,CAAC,SAAS,GAAG,GAAG,CAAC;YAC1D,OAAO,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAErF,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Components } from '../digest/read.ts';
2
+ import type { Annotation } from './types.ts';
3
+ /**
4
+ * The components this extension ships, which run inside its own service: the encounters only
5
+ * where the annotation serves them.
6
+ */
7
+ export declare function components(annotation?: Partial<Annotation>): Components;
@@ -0,0 +1,10 @@
1
+ import { components as digest } from '../digest/read.js';
2
+ import { ENCOUNTERS, NAMESPACE } from './const.js';
3
+ /**
4
+ * The components this extension ships, which run inside its own service: the encounters only
5
+ * where the annotation serves them.
6
+ */
7
+ export function components(annotation) {
8
+ return digest('extensions.chronicles', (label) => annotation?.encounters === true || label !== `${NAMESPACE}-${ENCOUNTERS}`);
9
+ }
10
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../source/extensions.chronicles/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,MAAM,EAAmB,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGlD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,UAAgC;IACzD,OAAO,MAAM,CACX,uBAAuB,EACvB,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,IAAI,KAAK,KAAK,GAAG,SAAS,IAAI,UAAU,EAAE,CACrF,CAAA;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** What the service is given of the annotation, as JSON, and what its secrets are named after. */
2
+ export declare const SETTINGS = "TOA_CHRONICLES";
3
+ /** The secret of the broker the rows are published to, and of the store they are read from. */
4
+ export declare const SECRET = "toa-chronicles";
5
+ /** Its keys: the users of the broker and of the store. */
6
+ export declare const KEYS: string[];
7
+ /** The namespace of the components this extension ships. */
8
+ export declare const NAMESPACE = "chronicles";
9
+ /** The service they run in, which is also the one consumer of the events the log is kept of. */
10
+ export declare const SERVICE = "relay";
11
+ /** The component that publishes the rows: of events, of facts `send` tasks it with, of encounters. */
12
+ export declare const RELAY = "relay";
13
+ /** The exchange of the broker the rows are published to, under the key of their table. */
14
+ export declare const EXCHANGE = "chronicles";
15
+ /** The component clients send encounters through, which documents them. */
16
+ export declare const ENCOUNTERS = "encounters";
17
+ /** The component the log is read through. */
18
+ export declare const QUERIES = "queries";
19
+ /** The stores Toa provides. */
20
+ export declare const PROVIDERS: readonly ['clickhouse'];
@@ -0,0 +1,26 @@
1
+ /** What the service is given of the annotation, as JSON, and what its secrets are named after. */
2
+ export const SETTINGS = 'TOA_CHRONICLES';
3
+ /** The secret of the broker the rows are published to, and of the store they are read from. */
4
+ export const SECRET = 'toa-chronicles';
5
+ /** Its keys: the users of the broker and of the store. */
6
+ export const KEYS = [
7
+ 'broker_username',
8
+ 'broker_password',
9
+ 'store_username',
10
+ 'store_password'
11
+ ];
12
+ /** The namespace of the components this extension ships. */
13
+ export const NAMESPACE = 'chronicles';
14
+ /** The service they run in, which is also the one consumer of the events the log is kept of. */
15
+ export const SERVICE = 'relay';
16
+ /** The component that publishes the rows: of events, of facts `send` tasks it with, of encounters. */
17
+ export const RELAY = 'relay';
18
+ /** The exchange of the broker the rows are published to, under the key of their table. */
19
+ export const EXCHANGE = 'chronicles';
20
+ /** The component clients send encounters through, which documents them. */
21
+ export const ENCOUNTERS = 'encounters';
22
+ /** The component the log is read through. */
23
+ export const QUERIES = 'queries';
24
+ /** The stores Toa provides. */
25
+ export const PROVIDERS = ['clickhouse'];
26
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../source/extensions.chronicles/const.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AAExC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAgB,CAAA;AAEtC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;CACjB,CAAA;AAED,4DAA4D;AAC5D,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAA;AAErC,gGAAgG;AAChG,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAE9B,sGAAsG;AACtG,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAA;AAE5B,0FAA0F;AAC1F,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAA;AAEpC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AAEtC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAEhC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,YAAY,CAAU,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Contribution } from '@toa.io/core/types';
2
+ /** What this extension puts on the context of a component that declares it. */
3
+ export declare function context(): Contribution[];
@@ -0,0 +1,11 @@
1
+ /** What this extension puts on the context of a component that declares it. */
2
+ export function context() {
3
+ return [
4
+ {
5
+ name: 'chronicles',
6
+ type: 'Chronicles',
7
+ imports: { '@toa.io/extensions.chronicles': ['Chronicles'] }
8
+ }
9
+ ];
10
+ }
11
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../source/extensions.chronicles/context.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,UAAU,OAAO;IACrB,OAAO;QACL;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,EAAE,+BAA+B,EAAE,CAAC,YAAY,CAAC,EAAE;SAC7D;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Contract } from './types.ts';
2
+ /**
3
+ * Refuses a contract a store could not read in types of its own: every property is one of the
4
+ * types the log has, described at every depth, and named so a store can name a column after it.
5
+ * `where` says whose contract it is, for the message.
6
+ */
7
+ export declare function check(contract: Contract, where: string): void;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Refuses a contract a store could not read in types of its own: every property is one of the
3
+ * types the log has, described at every depth, and named so a store can name a column after it.
4
+ * `where` says whose contract it is, for the message.
5
+ */
6
+ export function check(contract, where) {
7
+ for (const [name, property] of Object.entries(contract.properties)) {
8
+ if (OWN.has(name))
9
+ throw new Error(`Chronicles declare '${where}.${name}', which is a column of the row: the payload's '${name}' is read before the contract, and is not declared.`);
10
+ named(name, `${where}.${name}`);
11
+ inspect(property, `${where}.${name}`, true);
12
+ }
13
+ }
14
+ /** A name a store can name a column after, which it then need not quote. */
15
+ function named(name, path) {
16
+ if (!NAME.test(name))
17
+ throw new Error(`Chronicles declare '${path}': a property is named by letters, digits and underscores from a letter or an underscore.`);
18
+ }
19
+ function inspect(property, path, described) {
20
+ if (typeof property !== 'object' || property === null || Array.isArray(property))
21
+ throw new Error(`Chronicles declare '${path}', which is not a schema of a property.`);
22
+ const schema = property;
23
+ for (const key of Object.keys(schema))
24
+ if (!KEYS.has(key))
25
+ throw new Error(`Chronicles declare '${path}' with '${key}', which the log has no type for.`);
26
+ if (described && (typeof schema.description !== 'string' || schema.description === ''))
27
+ throw new Error(`Chronicles declare '${path}' with no description.`);
28
+ const type = schema.type;
29
+ if (typeof type !== 'string' || !TYPES.has(type))
30
+ throw new Error(`Chronicles declare '${path}' of the type '${JSON.stringify(type)}', which is not one of ${[...TYPES].join(', ')}.`);
31
+ if (schema.enum !== undefined && (type !== 'string' || !strings(schema.enum)))
32
+ throw new Error(`Chronicles declare '${path}' with an enum that is not of strings.`);
33
+ if (schema.format !== undefined &&
34
+ (typeof schema.format !== 'string' || !SCALARS.has(type)))
35
+ throw new Error(`Chronicles declare '${path}' with a format the type has none of.`);
36
+ if (type === 'object') {
37
+ const properties = schema.properties;
38
+ if (typeof properties !== 'object' ||
39
+ properties === null ||
40
+ Array.isArray(properties))
41
+ throw new Error(`Chronicles declare the object '${path}' with no properties.`);
42
+ for (const [key, nested] of Object.entries(properties)) {
43
+ named(key, `${path}.${key}`);
44
+ inspect(nested, `${path}.${key}`, true);
45
+ }
46
+ }
47
+ else if (schema.properties !== undefined)
48
+ throw new Error(`Chronicles declare '${path}' with properties, which is not an object.`);
49
+ if (type === 'array') {
50
+ if (schema.items === undefined)
51
+ throw new Error(`Chronicles declare the array '${path}' with no items.`);
52
+ // what the array is of is told by the array's description
53
+ inspect(schema.items, `${path}[]`, false);
54
+ }
55
+ else if (schema.items !== undefined)
56
+ throw new Error(`Chronicles declare '${path}' with items, which is not an array.`);
57
+ }
58
+ function strings(values) {
59
+ return (Array.isArray(values) &&
60
+ values.length > 0 &&
61
+ values.every((value) => typeof value === 'string'));
62
+ }
63
+ const SCALARS = new Set(['string', 'integer', 'number', 'boolean']);
64
+ const TYPES = new Set([...SCALARS, 'object', 'array']);
65
+ const KEYS = new Set(['type', 'description', 'enum', 'format', 'properties', 'items']);
66
+ const NAME = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
67
+ /** What a row of the log says of itself: columns of its own, beside the payload. */
68
+ const OWN = new Set(['id', 'time', 'received', 'entity', 'version', 'identity', 'trace']);
69
+ //# sourceMappingURL=contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../../source/extensions.chronicles/contract.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MA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GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Annotation } from './types.ts';
2
+ import type { context } from '@toa.io/norm';
3
+ import type { Dependency } from '@toa.io/operations';
4
+ /**
5
+ * The events the components declare are consumed, so they are published, and the service consumes
6
+ * them: it is given which they are and their contracts, the contracts of the facts, the store, and
7
+ * the store's credentials, which nothing else is.
8
+ * Where the events travel is the context's `amqp`, as it is for any receiver.
9
+ */
10
+ export declare function deployment(instances: context.Dependency[], annotation: Annotation | undefined): Dependency;
11
+ /** The extension is deployed for the sake of the annotation, which a component need not name. */
12
+ export declare const standalone = true;
@@ -0,0 +1,84 @@
1
+ import { components } from './components.js';
2
+ import { version } from '../version.js';
3
+ import { KEYS, NAMESPACE, SECRET, SERVICE, SETTINGS } from './const.js';
4
+ import * as schemas from './schemas.js';
5
+ /**
6
+ * The events the components declare are consumed, so they are published, and the service consumes
7
+ * them: it is given which they are and their contracts, the contracts of the facts, the store, and
8
+ * the store's credentials, which nothing else is.
9
+ * Where the events travel is the context's `amqp`, as it is for any receiver.
10
+ */
11
+ export function deployment(instances, annotation) {
12
+ // the components the extension ships are among the instances, and declare nothing to keep
13
+ const declaring = instances.filter((instance) => instance.locator.namespace !== NAMESPACE);
14
+ if (annotation === undefined)
15
+ throw new Error(`Chronicles are declared by '${declaring.map((instance) => instance.locator.id).join("', '")}', ` +
16
+ "and the context has no 'chronicles' annotation.");
17
+ schemas.annotation.validate(annotation, 'Invalid chronicles annotation');
18
+ const events = {};
19
+ const states = {};
20
+ const facts = {};
21
+ const identities = {};
22
+ const timestamps = {};
23
+ for (const instance of declaring) {
24
+ const declaration = instance.manifest ?? NONE;
25
+ const id = instance.locator.id;
26
+ for (const [event, contract] of Object.entries(declaration.events))
27
+ events[`${id}.${event}`] = contract;
28
+ if (declaration.state !== undefined) {
29
+ const { event, ...contract } = declaration.state;
30
+ states[`${id}.${event}`] = contract;
31
+ }
32
+ for (const [fact, contract] of Object.entries(declaration.facts))
33
+ facts[`${id}.${fact}`] = contract;
34
+ if (declaration.identity !== null)
35
+ identities[id] = declaration.identity;
36
+ timestamps[id] = declaration.timestamp;
37
+ }
38
+ const settings = {
39
+ ...read(annotation),
40
+ events,
41
+ states,
42
+ facts,
43
+ identities,
44
+ timestamps
45
+ };
46
+ const { labels } = components(annotation);
47
+ const service = {
48
+ group: NAMESPACE,
49
+ name: SERVICE,
50
+ version,
51
+ components: labels,
52
+ variables: [{ name: SETTINGS, value: JSON.stringify(settings) }, ...credentials()]
53
+ };
54
+ if (annotation.resources !== undefined)
55
+ service.resources = annotation.resources;
56
+ // a state's event is consumed as an event's is
57
+ return {
58
+ services: [service],
59
+ events: [...new Set([...Object.keys(events), ...Object.keys(states)])]
60
+ };
61
+ }
62
+ /** The extension is deployed for the sake of the annotation, which a component need not name. */
63
+ export const standalone = true;
64
+ function read(annotation) {
65
+ // what is read is the user's own: the address names a server, and no database of it
66
+ if (new URL(annotation.store.url).pathname.replace(/\//g, '') !== '')
67
+ throw new Error("The store of chronicles is the address of a server: what is read is its user's.");
68
+ return {
69
+ broker: annotation.broker,
70
+ store: annotation.store,
71
+ retention: annotation.retention,
72
+ encounters: annotation.encounters === true,
73
+ ip: annotation.ip ?? 'truncated'
74
+ };
75
+ }
76
+ /** The user the store is provisioned as, and the password of the reader it creates. */
77
+ function credentials() {
78
+ return KEYS.map((key) => ({
79
+ name: `${SETTINGS}_${key.toUpperCase()}`,
80
+ secret: { name: SECRET, key }
81
+ }));
82
+ }
83
+ const NONE = { events: {}, facts: {}, identity: null, timestamp: null };
84
+ //# sourceMappingURL=deployment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../source/extensions.chronicles/deployment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB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CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACvE,CAAA;AACH,CAAC;AAED,iGAAiG;AACjG,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAA;AAE9B,SAAS,IAAI,CACX,UAAsB;IAEtB,oFAAoF;IACpF,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE;QAClE,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAA;IAEH,OAAO;QACL,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,UAAU,EAAE,UAAU,CAAC,UAAU,KAAK,IAAI;QAC1C,EAAE,EAAE,UAAU,CAAC,EAAE,IAAI,WAAW;KACjC,CAAA;AACH,CAAC;AAED,uFAAuF;AACvF,SAAS,WAAW;IAClB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxB,IAAI,EAAE,GAAG,QAAQ,IAAI,GAAG,CAAC,WAAW,EAAE,EAAE;QACxC,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE;KAC9B,CAAC,CAAC,CAAA;AACL,CAAC;AAED,MAAM,IAAI,GAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ export { manifest } from './manifest.ts';
2
+ export { components } from './components.ts';
3
+ export { deployment, standalone } from './deployment.ts';
4
+ export { context } from './context.ts';
5
+ export * from './const.ts';
6
+ export * as schemas from './schemas.ts';
7
+ export type { Address, Annotation, Contract, Declaration, Declared, Property, Settings, State, Store } from './types.ts';
@@ -0,0 +1,7 @@
1
+ export { manifest } from './manifest.js';
2
+ export { components } from './components.js';
3
+ export { deployment, standalone } from './deployment.js';
4
+ export { context } from './context.js';
5
+ export * from './const.js';
6
+ export * as schemas from './schemas.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/extensions.chronicles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,cAAc,YAAY,CAAA;AAC1B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Declaration, Declared } from './types.ts';
2
+ import type { Manifest } from '@toa.io/norm';
3
+ /**
4
+ * The `chronicles:` block of a component manifest: the events whose renderings are rows of the
5
+ * log, the one whose payload is the entity as it stands, and the facts the component sends, each
6
+ * with the contract of what is written of it. Norm hands over the whole manifest, prototype events
7
+ * included, so a label is checked here rather than left to fail at boot.
8
+ *
9
+ * `chronicles: ~` is a component that logs nothing; it has to produce a value or norm rejects the
10
+ * extension.
11
+ */
12
+ export declare function manifest(declared: Declared | undefined, component: Manifest): Declaration;
@@ -0,0 +1,63 @@
1
+ import * as schemas from './schemas.js';
2
+ import { check } from './contract.js';
3
+ /**
4
+ * The `chronicles:` block of a component manifest: the events whose renderings are rows of the
5
+ * log, the one whose payload is the entity as it stands, and the facts the component sends, each
6
+ * with the contract of what is written of it. Norm hands over the whole manifest, prototype events
7
+ * included, so a label is checked here rather than left to fail at boot.
8
+ *
9
+ * `chronicles: ~` is a component that logs nothing; it has to produce a value or norm rejects the
10
+ * extension.
11
+ */
12
+ export function manifest(declared, component) {
13
+ const declaration = normalize(declared);
14
+ schemas.declaration.validate(declaration, 'Invalid chronicles declaration');
15
+ const name = id(component);
16
+ const events = Object.keys(declaration.events);
17
+ if (declaration.state !== undefined)
18
+ events.push(declaration.state.event);
19
+ for (const event of events)
20
+ if (component.events?.[event] === undefined)
21
+ throw new Error(`Chronicles of '${name}' name '${event}', which is not an event of the component.`);
22
+ for (const [event, contract] of Object.entries(declaration.events))
23
+ check(contract, `${name}.${event}`);
24
+ if (declaration.state !== undefined)
25
+ check(declaration.state, `${name}.${declaration.state.event}`);
26
+ for (const [fact, contract] of Object.entries(declaration.facts))
27
+ check(contract, `${name}.${fact}`);
28
+ // the default may name nothing of the entity, and reads as none where it does not; a property
29
+ // the component names is one it means to have
30
+ const named = declared?.identity !== undefined;
31
+ const properties = component.entity?.properties;
32
+ if (named &&
33
+ declaration.identity !== null &&
34
+ properties !== undefined &&
35
+ !(declaration.identity in properties))
36
+ throw new Error(`Chronicles of '${name}' name the identity '${declaration.identity}', ` +
37
+ 'which is not a property of the entity.');
38
+ return declaration;
39
+ }
40
+ /**
41
+ * `identity` unless the component names another property, or none with `identity: ~`; `UPDATED`
42
+ * unless it names another of when a change was made, or none with `timestamp: ~`.
43
+ */
44
+ function normalize(declared) {
45
+ if (declared === null || declared === undefined)
46
+ return { events: {}, facts: {}, identity: IDENTITY, timestamp: TIMESTAMP };
47
+ return {
48
+ ...declared,
49
+ events: declared.events ?? {},
50
+ facts: declared.facts ?? {},
51
+ identity: declared.identity === undefined ? IDENTITY : declared.identity,
52
+ timestamp: declared.timestamp === undefined ? TIMESTAMP : declared.timestamp
53
+ };
54
+ }
55
+ const IDENTITY = 'identity';
56
+ /** what an entity as it stands says of when it last changed */
57
+ const TIMESTAMP = 'UPDATED';
58
+ function id(component) {
59
+ return component.namespace === undefined || component.namespace === 'default'
60
+ ? component.name
61
+ : `${component.namespace}.${component.name}`;
62
+ }
63
+ //# sourceMappingURL=manifest.js.map