ddd-ts-kit 0.93.0 → 0.94.1

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 (90) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.fr.md +2 -2
  3. package/README.md +1 -1
  4. package/dist/check/authz/modelled-permissions.d.ts +32 -0
  5. package/dist/check/authz/modelled-permissions.d.ts.map +1 -0
  6. package/dist/check/authz/modelled-permissions.js +169 -0
  7. package/dist/check/authz/modelled-permissions.js.map +1 -0
  8. package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
  9. package/dist/check/catalogue/architecture-rules.js +4 -0
  10. package/dist/check/catalogue/architecture-rules.js.map +1 -1
  11. package/dist/check/explain/authz-docs.d.ts.map +1 -1
  12. package/dist/check/explain/authz-docs.js +17 -0
  13. package/dist/check/explain/authz-docs.js.map +1 -1
  14. package/dist/check/explain/scheduling-docs.d.ts.map +1 -1
  15. package/dist/check/explain/scheduling-docs.js +7 -0
  16. package/dist/check/explain/scheduling-docs.js.map +1 -1
  17. package/dist/check/fixtures/authz-resource-modelled-fixtures.d.ts +3 -0
  18. package/dist/check/fixtures/authz-resource-modelled-fixtures.d.ts.map +1 -0
  19. package/dist/check/fixtures/authz-resource-modelled-fixtures.js +194 -0
  20. package/dist/check/fixtures/authz-resource-modelled-fixtures.js.map +1 -0
  21. package/dist/check/fixtures/fixtures.d.ts.map +1 -1
  22. package/dist/check/fixtures/fixtures.js +2 -0
  23. package/dist/check/fixtures/fixtures.js.map +1 -1
  24. package/dist/check/fixtures/scheduling-fixtures.d.ts.map +1 -1
  25. package/dist/check/fixtures/scheduling-fixtures.js +69 -1
  26. package/dist/check/fixtures/scheduling-fixtures.js.map +1 -1
  27. package/dist/check/rules/authz-resource-modelled.d.ts +13 -0
  28. package/dist/check/rules/authz-resource-modelled.d.ts.map +1 -0
  29. package/dist/check/rules/authz-resource-modelled.js +128 -0
  30. package/dist/check/rules/authz-resource-modelled.js.map +1 -0
  31. package/dist/check/rules/scheduling-tenancy-declared.d.ts +3 -0
  32. package/dist/check/rules/scheduling-tenancy-declared.d.ts.map +1 -0
  33. package/dist/check/rules/scheduling-tenancy-declared.js +45 -0
  34. package/dist/check/rules/scheduling-tenancy-declared.js.map +1 -0
  35. package/dist/check/scheduling/job-names.d.ts +1 -1
  36. package/dist/check/scheduling/job-names.d.ts.map +1 -1
  37. package/dist/check/scheduling/job-names.js +3 -21
  38. package/dist/check/scheduling/job-names.js.map +1 -1
  39. package/dist/check/scheduling/jobs-declared.d.ts +11 -0
  40. package/dist/check/scheduling/jobs-declared.d.ts.map +1 -0
  41. package/dist/check/scheduling/jobs-declared.js +24 -0
  42. package/dist/check/scheduling/jobs-declared.js.map +1 -0
  43. package/dist/generate/access-vars.js +18 -0
  44. package/dist/generate/access-vars.js.map +1 -1
  45. package/dist/generate/kinds/job/grant-system-actor.js +2 -2
  46. package/dist/generate/kinds/job/grant-system-actor.js.map +1 -1
  47. package/dist/generate/kinds/job-kind.js +1 -1
  48. package/dist/generate/kinds/job-kind.js.map +1 -1
  49. package/dist/init/files/platform-files.js +1 -0
  50. package/dist/init/files/platform-files.js.map +1 -1
  51. package/dist/init/manifest/versions.js +24 -24
  52. package/dist/platform-layout/platform-layout.d.ts +1 -0
  53. package/dist/platform-layout/platform-layout.d.ts.map +1 -1
  54. package/dist/platform-layout/platform-layout.js +1 -0
  55. package/dist/platform-layout/platform-layout.js.map +1 -1
  56. package/dist/presets/apply-preset.d.ts.map +1 -1
  57. package/dist/presets/apply-preset.js +4 -0
  58. package/dist/presets/apply-preset.js.map +1 -1
  59. package/dist/presets/organisations-as-tenant-directory.d.ts +10 -0
  60. package/dist/presets/organisations-as-tenant-directory.d.ts.map +1 -0
  61. package/dist/presets/organisations-as-tenant-directory.js +16 -0
  62. package/dist/presets/organisations-as-tenant-directory.js.map +1 -0
  63. package/dist/version.d.ts +1 -1
  64. package/dist/version.js +1 -1
  65. package/package.json +4 -4
  66. package/templates/command/command.ts.tpl +3 -0
  67. package/templates/file-upload/command.ts.tpl +3 -0
  68. package/templates/init/docker/env.example.tpl +2 -1
  69. package/templates/init/platform/audit/audit.module.tsyringe.ts.tpl +1 -1
  70. package/templates/init/platform/auth/relationships/relationship-schema.ts.tpl +24 -9
  71. package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +5 -5
  72. package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +13 -17
  73. package/templates/init/platform/composition/tenant-directory.ts.tpl +14 -0
  74. package/templates/init/platform/config/app-config.ts.tpl +1 -1
  75. package/templates/init/platform/files/files.module.tsyringe.ts.tpl +1 -1
  76. package/templates/init/platform/privacy/privacy.module.tsyringe.ts.tpl +1 -1
  77. package/templates/init/scripts/privacy-erase.manual.ts.tpl +18 -8
  78. package/templates/init/scripts/privacy-erase.tsyringe.ts.tpl +18 -8
  79. package/templates/init/scripts/privacy-export.manual.ts.tpl +17 -7
  80. package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +17 -7
  81. package/templates/job/job.spec.tsyringe.ts.tpl +1 -1
  82. package/templates/pipeline/github/workflows/ci.yml.tpl +2 -0
  83. package/templates/pipeline/gitlab/gitlab-ci.yml.tpl +2 -0
  84. package/templates/pipeline/package-scripts.json +1 -1
  85. package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation-tenant-directory.reader.drizzle.ts.tpl +26 -0
  86. package/templates/presets/identity/context/infrastructure/persistence/knex-organisation-tenant-directory.reader.knex.ts.tpl +30 -0
  87. package/templates/presets/identity/context/infrastructure/persistence/prisma-organisation-tenant-directory.reader.prisma.ts.tpl +25 -0
  88. package/templates/presets/identity/context/test/integration/organisation-tenant-directory.spec.ts.tpl +107 -0
  89. package/templates/presets/identity/platform/tenant-directory.ts.tpl +13 -0
  90. package/templates/query/query.ts.tpl +3 -0
@@ -0,0 +1,194 @@
1
+ import { CONFIG_FILE } from '../../config/index.js';
2
+ import { config } from './config.js';
3
+ import { PATHS } from './paths.js';
4
+ import { project } from './project.js';
5
+ import { SAMPLES } from './samples.js';
6
+ import { source } from './source.js';
7
+ const { BILLING, COMMAND, QUERY, QUERY_HANDLER, QUERY_HANDLER_SPEC } = PATHS;
8
+ const PERMISSIONS = `${BILLING}/billing.permissions.ts`;
9
+ const SCHEMA = 'src/platform/auth/relationships/relationship-schema.ts';
10
+ const REBAC = { [CONFIG_FILE]: config({ stack: { authz: 'rebac' } }) };
11
+ const DECLARED = source("import { definePermissions } from '@ddd-ts-kit/auth';", '', "export const billingPermissions = definePermissions('billing', {", " 'invoice.issue': { description: 'Issue invoice' },", " 'invoice.search': { description: 'Search invoice' },", '});');
12
+ const SEARCH_HANDLER = source("import type { Access } from '@ddd-ts-kit/auth';", "import { billingPermissions } from '@/contexts/billing/billing.permissions.js';", "import type { InvoicesIssuedQuery } from '@/contexts/billing/application/queries/invoices-issued/invoices-issued.query.js';", '', 'export class InvoicesIssuedHandler {', ' constructor(private readonly access: Access) {}', '', ' async execute(query: InvoicesIssuedQuery): Promise<unknown> {', " return this.access.scope(query.actor, billingPermissions['invoice.search'], 'invoice');", ' }', '}');
13
+ const ISSUE = "billingPermissions['invoice.issue']";
14
+ const ON_THE_CONTEXT = "resource: () => ({ type: 'context', id: 'billing' })";
15
+ const ON_THE_INVOICE = "resource: (command) => ({ type: 'invoice', id: command.invoiceId })";
16
+ const rule = 'authz/resource-modelled';
17
+ export const AUTHZ_RESOURCE_MODELLED_FIXTURES = [
18
+ {
19
+ ruleId: rule,
20
+ name: 'a permission derived on the invoice, checked on the invoice',
21
+ expect: 'pass',
22
+ files: requiring(ON_THE_INVOICE, elements(`[${ISSUE}.id]: 'owner'`)),
23
+ },
24
+ {
25
+ ruleId: rule,
26
+ name: 'a permission no element derives, checked on the context',
27
+ expect: 'pass',
28
+ files: requiring(ON_THE_CONTEXT, elements()),
29
+ },
30
+ {
31
+ ruleId: rule,
32
+ name: 'a relation derived on the invoice that is no permission (edit), a permission checked on the context',
33
+ expect: 'pass',
34
+ files: requiring(ON_THE_CONTEXT, elements("edit: 'owner'")),
35
+ },
36
+ {
37
+ ruleId: rule,
38
+ name: 'a permission derived on the context itself, checked on the context',
39
+ expect: 'pass',
40
+ files: requiring(ON_THE_CONTEXT, elements(), { context: `[${ISSUE}.id]: 'operator'` }),
41
+ },
42
+ {
43
+ ruleId: rule,
44
+ name: 'a permission derived on an element, in a project whose rights are roles',
45
+ expect: 'pass',
46
+ files: requiring(ON_THE_CONTEXT, elements(`[${ISSUE}.id]: 'owner'`), { overrides: { stack: { authz: 'rbac' } } }),
47
+ },
48
+ {
49
+ ruleId: rule,
50
+ name: 'a permission derived on the invoice, checked on the context',
51
+ expect: { file: COMMAND },
52
+ files: requiring(ON_THE_CONTEXT, elements(`[${ISSUE}.id]: 'owner'`)),
53
+ },
54
+ {
55
+ ruleId: rule,
56
+ name: 'a permission derived on the invoice by its id, checked on the context',
57
+ expect: { file: COMMAND },
58
+ files: requiring(ON_THE_CONTEXT, elements("'billing:invoice.issue': 'owner'")),
59
+ },
60
+ {
61
+ ruleId: rule,
62
+ name: 'a permission derived on the invoice by a constant of the schema file, checked on the context',
63
+ expect: { file: COMMAND },
64
+ files: requiring(ON_THE_CONTEXT, elements("[issue]: 'owner'", { before: `const issue = ${ISSUE}.id;` })),
65
+ },
66
+ {
67
+ ruleId: rule,
68
+ name: 'a permission derived on the invoice in the schema written in place, checked on the context',
69
+ expect: { file: COMMAND },
70
+ files: requiring(ON_THE_CONTEXT, inline(`[${ISSUE}.id]: 'owner'`)),
71
+ },
72
+ {
73
+ ruleId: rule,
74
+ name: 'a search whose gate and scope share a permission the schema derives on the invoice',
75
+ expect: { file: QUERY },
76
+ files: searching(),
77
+ },
78
+ {
79
+ ruleId: rule,
80
+ name: 'a search whose gate is on the context, which still derives every permission, the scope on the invoice',
81
+ expect: 'pass',
82
+ files: searching("context: { relations: { operator: ['user'] }, derived: Object.fromEntries(permissions.all().map((permission) => [permission.id, 'operator'])) }"),
83
+ },
84
+ {
85
+ ruleId: rule,
86
+ name: 'a schema whose types are given by a call',
87
+ expect: { file: SCHEMA },
88
+ files: requiring(ON_THE_INVOICE, written('defineSchema(typesOf())')),
89
+ },
90
+ {
91
+ ruleId: rule,
92
+ name: 'a type written as a shorthand property',
93
+ expect: { file: SCHEMA },
94
+ files: requiring(ON_THE_INVOICE, written('defineSchema({ user: {}, invoice })')),
95
+ },
96
+ {
97
+ ruleId: rule,
98
+ name: 'a type held in a constant of the file',
99
+ expect: { file: SCHEMA },
100
+ files: requiring(ON_THE_INVOICE, written('defineSchema({ user: {}, invoice: invoiceType })')),
101
+ },
102
+ {
103
+ ruleId: rule,
104
+ name: 'the derived relations of a type given by a call',
105
+ expect: { file: SCHEMA },
106
+ files: requiring(ON_THE_INVOICE, written('defineSchema({ user: {}, invoice: { derived: derivedOf() } })')),
107
+ },
108
+ {
109
+ ruleId: rule,
110
+ name: 'a derived key held in a constant the file does not declare',
111
+ expect: { file: SCHEMA },
112
+ files: requiring(ON_THE_INVOICE, elements("[issue]: 'owner'")),
113
+ },
114
+ {
115
+ ruleId: rule,
116
+ name: 'a search whose gate is on the context, which lists the permission among those it derives, the scope on the invoice',
117
+ expect: 'pass',
118
+ files: searching("context: { relations: { operator: ['user'] }, derived: { [billingPermissions['invoice.search'].id]: 'operator' } }"),
119
+ },
120
+ {
121
+ ruleId: rule,
122
+ name: 'a search whose gate is on the context, which derives only the permissions no element derives',
123
+ expect: { file: QUERY },
124
+ files: searching("context: { relations: { operator: ['user'] }, derived: Object.fromEntries(permissions.all().filter((permission) => !modelled.has(permission.id)).map((permission) => [permission.id, 'operator'])) }"),
125
+ },
126
+ {
127
+ ruleId: rule,
128
+ name: 'a requirement whose permission the checker cannot read',
129
+ expect: 'pass',
130
+ files: requiring(ON_THE_INVOICE, elements(`[${ISSUE}.id]: 'owner'`), { permission: 'permissionHeldElsewhere' }),
131
+ },
132
+ {
133
+ ruleId: rule,
134
+ name: 'a requirement with no resource, for a permission derived on the invoice',
135
+ expect: { file: COMMAND },
136
+ files: requiring('', elements(`[${ISSUE}.id]: 'owner'`)),
137
+ },
138
+ {
139
+ ruleId: rule,
140
+ name: 'a requirement whose resource the checker cannot read, for a permission derived on the invoice',
141
+ expect: { file: COMMAND },
142
+ files: requiring('resource: resourceOf', elements(`[${ISSUE}.id]: 'owner'`)),
143
+ },
144
+ {
145
+ ruleId: rule,
146
+ name: 'a schema that spreads something other than its elements',
147
+ expect: { file: SCHEMA },
148
+ files: requiring(ON_THE_INVOICE, source("import { defineSchema } from '@ddd-ts-kit/auth/rebac';", '', 'export const relationshipSchema = defineSchema({ user: {}, ...others });')),
149
+ },
150
+ {
151
+ ruleId: rule,
152
+ name: 'a schema built by a call',
153
+ expect: { file: SCHEMA },
154
+ files: requiring(ON_THE_INVOICE, source('export const relationshipSchema = buildSchema();')),
155
+ },
156
+ {
157
+ ruleId: rule,
158
+ name: 'a derived key computed in a way the checker cannot resolve',
159
+ expect: { file: SCHEMA },
160
+ files: requiring(ON_THE_INVOICE, elements("[permissionOf('invoice.issue')]: 'owner'")),
161
+ },
162
+ ];
163
+ /** A schema file whose `defineSchema` call is as written. */
164
+ function written(call) {
165
+ return source("import { defineSchema } from '@ddd-ts-kit/auth/rebac';", '', `export const relationshipSchema = ${call};`);
166
+ }
167
+ /** The schema of the platform with the elements in `elements`; `derived` is the body of the derived relations of the invoice. */
168
+ function elements(derived = "edit: 'owner'", { before } = {}) {
169
+ return source("import { defineSchema, type SchemaDefinition } from '@ddd-ts-kit/auth/rebac';", "import { billingPermissions } from '@/contexts/billing/billing.permissions.js';", '', ...(before === undefined ? [] : [before, '']), 'const elements: SchemaDefinition = {', ` invoice: { relations: { owner: ['user'] }, derived: { ${derived} } },`, '};', '', 'export const relationshipSchema = defineSchema({', ' user: {},', " context: { relations: { operator: ['user'] } },", ' ...elements,', '});', '', 'export const used = billingPermissions;');
170
+ }
171
+ /** A schema written as projects generated before `elements` wrote it: the invoice in place, the context deriving `derived` too. */
172
+ function inline(derived) {
173
+ return source("import { defineSchema } from '@ddd-ts-kit/auth/rebac';", "import { billingPermissions } from '@/contexts/billing/billing.permissions.js';", '', 'export const relationshipSchema = defineSchema({', ' user: {},', " context: { relations: { operator: ['user'] } },", ` invoice: { relations: { owner: ['user'] }, derived: { ${derived} } },`, '});', '', 'export const used = billingPermissions;');
174
+ }
175
+ function requiring(resource, schema, { context, overrides = {}, permission = ISSUE, } = {}) {
176
+ return project({
177
+ [PERMISSIONS]: DECLARED,
178
+ [SCHEMA]: context === undefined
179
+ ? schema
180
+ : schema.replace("context: { relations: { operator: ['user'] } }", `context: { relations: { operator: ['user'] }, derived: { ${context} } }`),
181
+ [COMMAND]: source("import { AuthorizedCommand } from '@ddd-ts-kit/kernel';", "import { Requires } from '@ddd-ts-kit/kernel/declarations';", "import { billingPermissions } from '@/contexts/billing/billing.permissions.js';", '', `@Requires(${permission}, { ${resource} })`, 'export class IssueInvoiceCommand extends AuthorizedCommand<void> {}'),
182
+ }, { [CONFIG_FILE]: config({ stack: { authz: 'rebac' }, ...overrides }) });
183
+ }
184
+ /** A search gated on the context and narrowed by the same permission, which the schema derives on the invoice. */
185
+ function searching(context = "context: { relations: { operator: ['user'] } }") {
186
+ return project({
187
+ [PERMISSIONS]: DECLARED,
188
+ [SCHEMA]: elements("[billingPermissions['invoice.search'].id]: 'owner'").replace("context: { relations: { operator: ['user'] } }", context),
189
+ [QUERY]: source("import { AuthorizedQuery } from '@ddd-ts-kit/kernel';", "import { Requires } from '@ddd-ts-kit/kernel/declarations';", "import { billingPermissions } from '@/contexts/billing/billing.permissions.js';", '', `@Requires(billingPermissions['invoice.search'], { ${ON_THE_CONTEXT} })`, 'export class InvoicesIssuedQuery extends AuthorizedQuery<unknown> {}'),
190
+ [QUERY_HANDLER]: SEARCH_HANDLER,
191
+ [QUERY_HANDLER_SPEC]: SAMPLES.SPEC,
192
+ }, REBAC);
193
+ }
194
+ //# sourceMappingURL=authz-resource-modelled-fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authz-resource-modelled-fixtures.js","sourceRo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E;QACD,CAAC,aAAa,CAAC,EAAE,cAAc;QAC/B,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC,IAAI;KACnC,EACD,KAAK,CACN,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/fixtures.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EAsDtC,CAAC"}
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/fixtures.ts"],"names":[],"mappings":"AAsDA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,OAAO,EAuDtC,CAAC"}
@@ -5,6 +5,7 @@ import { AUTHZ_FIXTURES } from './authz-fixtures.js';
5
5
  import { AUTHZ_GRANTED_FIXTURES } from './authz-granted-fixtures.js';
6
6
  import { AUTHZ_POLICY_FIXTURES } from './authz-policy-fixtures.js';
7
7
  import { AUTHZ_SCOPE_NARROWS_FIXTURES } from './authz-scope-narrows-fixtures.js';
8
+ import { AUTHZ_RESOURCE_MODELLED_FIXTURES } from './authz-resource-modelled-fixtures.js';
8
9
  import { CLEAN_FIXTURES } from './clean-fixtures.js';
9
10
  import { COMPOSITION_FIXTURES } from './composition-fixtures.js';
10
11
  import { CONFIG_FIXTURES } from './config-fixtures.js';
@@ -63,6 +64,7 @@ export const FIXTURES = [
63
64
  ...AUTHZ_POLICY_FIXTURES,
64
65
  ...AUTHZ_GRANTED_FIXTURES,
65
66
  ...AUTHZ_SCOPE_NARROWS_FIXTURES,
67
+ ...AUTHZ_RESOURCE_MODELLED_FIXTURES,
66
68
  ...CLEAN_FIXTURES,
67
69
  ...COMPOSITION_FIXTURES,
68
70
  ...CONFIG_FIXTUR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IACzB,GAAG,eAAe;IAClB,GAAG,uBAAuB;IAC1B,GAAG,eAAe;IAClB,GAAG,kBAAkB;IACrB,GAAG,oBAAoB;IACvB,GAAG,cAAc;IACjB,GAAG,mBAAmB;IACtB,GAAG,gBAAgB;IACnB,GAAG,iBAAiB;IACpB,GAAG,mBAAmB;IACtB,GAAG,uBAAuB;IAC1B,GAAG,cAAc;IACjB,GAAG,eAAe;IAClB,GAAG,kBAAkB;IACrB,GAAG,eAAe;IAClB,GAAG,eAAe;IAClB,GAAG,sBAAsB;IACzB,GAAG,eAAe;IAClB,GAAG,oBAAoB;IACvB,GAAG,cAAc;IACjB,GAAG,eAAe;IAClB,GAAG,mBAAmB;IACtB,GAAG,iBAAiB;IACpB,GAAG,aAAa;IAChB,GAAG,yBAAyB;IAC5B,GAAG,gBAAgB;IACnB,GAAG,gBAAgB;IACnB,GAAG,aAAa;IAChB,GAAG,gBAAgB;IACnB,GAAG,aAAa;IAChB,GAAG,0BAA0B;IAC7B,GAAG,uBAAuB;CAC3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"scheduling-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/scheduling-fixtures.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuJzC,eAAO,MAAM,mBAAmB,EAAE,SAAS,OAAO,EAAwC,CAAC"}
1
+ {"version":3,"file":"scheduling-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/scheduling-fixtures.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiOzC,eAAO,MAAM,mBAAmB,EAAE,SAAS,OAAO,EAA6D,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { CONFIG_FILE } from '../../config/index.js';
2
+ import { config } from './config.js';
1
3
  import { DECLARED } from './declared.js';
2
4
  import { declaredProject } from './declared-project.js';
3
5
  import { PATHS } from './paths.js';
@@ -122,8 +124,74 @@ const JOB_NAME = [
122
124
  }),
123
125
  },
124
126
  ];
125
- export const SCHEDULING_FIXTURES = [...TRIGGERS_USE_CASE, ...JOB_NAME];
127
+ const TENANCY_RULE = 'scheduling/tenancy-declared';
128
+ const TENANT_CONFIG = { [CONFIG_FILE]: config({ stack: { style: 'declared', tenancy: 'shared-table' } }) };
129
+ const PER_TENANT = "{ every: '15m', tenancy: 'per-tenant' }";
130
+ const TENANCY_DECLARED = [
131
+ {
132
+ ruleId: TENANCY_RULE,
133
+ name: 'a job that runs per tenant',
134
+ expect: 'pass',
135
+ files: declaredProject({ [JOB]: tenantJob(PER_TENANT), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
136
+ },
137
+ {
138
+ ruleId: TENANCY_RULE,
139
+ name: 'a job that is global on purpose',
140
+ expect: 'pass',
141
+ files: declaredProject({ [JOB]: tenantJob("{ every: '15m', tenancy: 'global' }"), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
142
+ },
143
+ {
144
+ ruleId: TENANCY_RULE,
145
+ name: 'a job without tenancy, in a project without tenants',
146
+ expect: 'pass',
147
+ files: declaredProject({ [JOB]: DECLARED.job, [JOB_SPEC]: SPEC }),
148
+ },
149
+ {
150
+ ruleId: TENANCY_RULE,
151
+ name: 'a job that does not say whether it runs per tenant or globally',
152
+ expect: { file: JOB },
153
+ files: declaredProject({ [JOB]: DECLARED.job, [JOB_SPEC]: SPEC }, TENANT_CONFIG),
154
+ },
155
+ {
156
+ ruleId: TENANCY_RULE,
157
+ name: 'explicit style: a job registered by the module file without tenancy',
158
+ expect: { file: MODULE },
159
+ files: project({
160
+ [JOB]: PLAIN_JOB,
161
+ [JOB_SPEC]: SPEC,
162
+ [MODULE]: moduleRegistering('@/contexts/billing/application/scheduling/send-reminders.job.js', 'billing.send-reminders'),
163
+ }, { [CONFIG_FILE]: config({ stack: { tenancy: 'shared-table' } }) }),
164
+ },
165
+ {
166
+ ruleId: TENANCY_RULE,
167
+ name: 'options the checker cannot read, a constant',
168
+ expect: { file: JOB },
169
+ files: declaredProject({ [JOB]: tenantJob('JOB_OPTIONS'), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
170
+ },
171
+ {
172
+ ruleId: TENANCY_RULE,
173
+ name: 'options the checker cannot read, a spread',
174
+ expect: { file: JOB },
175
+ files: declaredProject({ [JOB]: tenantJob("{ ...BASE, every: '15m' }"), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
176
+ },
177
+ {
178
+ ruleId: TENANCY_RULE,
179
+ name: 'a tenancy the checker cannot read, a constant',
180
+ expect: { file: JOB },
181
+ files: declaredProject({ [JOB]: tenantJob("{ every: '15m', tenancy: TENANCY }"), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
182
+ },
183
+ {
184
+ ruleId: TENANCY_RULE,
185
+ name: 'a tenancy written as a shorthand',
186
+ expect: { file: JOB },
187
+ files: declaredProject({ [JOB]: tenantJob("{ every: '15m', tenancy }"), [JOB_SPEC]: SPEC }, TENANT_CONFIG),
188
+ },
189
+ ];
190
+ export const SCHEDULING_FIXTURES = [...TRIGGERS_USE_CASE, ...JOB_NAME, ...TENANCY_DECLARED];
126
191
  function moduleRegistering(jobFile, name) {
127
192
  return source("import { defineModule } from '@ddd-ts-kit/di';", "import { CommandBus } from '@ddd-ts-kit/kernel';", `import { SendRemindersJob } from '${jobFile}';`, '', "export const billingModule = defineModule('billing', (builder) => {", ` builder.job('${name}', { every: '15m' }).handledBy(SendRemindersJob, [CommandBus]);`, '});');
128
193
  }
194
+ function tenantJob(options) {
195
+ return DECLARED.job.replace("{ every: '15m' }", options);
196
+ }
129
197
  //# sourceMappingURL=scheduling-fixtures.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduling-fixtures.js","sourceRoot":"","sources":["../../../src/check/fixtures/scheduling-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA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AAG,CAAC,EAAE,SAAS,CAAC,oCAAoC,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,aAAa,CAAC;KACpH;IACD;QACE,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,kCAAkC;QACxC,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;QACrB,KAAK,EAAE,eAAe,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,2BAA2B,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,aAAa,CAAC;KAC3G;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAuB,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,CAAC;AAEhH,SAAS,iBAAiB,CAAC,OAAe,EAAE,IAAY;IACtD,OAAO,MAAM,CACX,gDAAgD,EAChD,kDAAkD,EAClD,qCAAqC,OAAO,IAAI,EAChD,EAAE,EACF,qEAAqE,EACrE,kBAAkB,IAAI,iEAAiE,EACvF,KAAK,CACN,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Rule } from '../model/rule.js';
2
+ /**
3
+ * Under relationships, a requirement names the element its permission is checked on. A permission
4
+ * the relationship schema derives on an element type is not held on the context (the operators
5
+ * of the context do not have it): a requirement whose resource is `{ type: 'context' }` for it is
6
+ * refused at run time, or, if the project's bridge grants it widely, granted to everybody. Judged:
7
+ * the permissions the types other than `context` derive in the schema file of the platform, against
8
+ * the resource of every `@Requires`, `.requires(` and `requires(` outside the tests. What it cannot
9
+ * read is said, never taken as safe: a schema built by a call or spread, a key computed in another
10
+ * way, a resource that is not an object literal with a literal `type`.
11
+ */
12
+ export declare const authzResourceModelled: Rule;
13
+ //# sourceMappingURL=authz-resource-modelled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authz-resource-modelled.d.ts","sourceRoot":"","sources":["../../../src/check/rules/authz-resource-modelled.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAe1C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAUnC,CAAC"}
@@ -0,0 +1,128 @@
1
+ import { modelledPermissions } from '../authz/modelled-permissions.js';
2
+ import { isInProject } from '../authz/is-in-project.js';
3
+ import { permissionSets } from '../authz/permission-sets.js';
4
+ import { scopedPermission } from '../authz/scoped-permission.js';
5
+ import { reporter } from '../support/reporter.js';
6
+ import { toViolations } from '../support/to-violations.js';
7
+ import { callArguments } from '../text/call-arguments.js';
8
+ import { platformFileIn } from '../../platform-layout/index.js';
9
+ /** `@Requires(`, `.requires(` and the `requires(` of an explicit module, the opening parenthesis last. */
10
+ const REQUIREMENT = /(?:@Requires|\.requires|\brequires)\s*\(/g;
11
+ const SCOPE_CALL = /([\w$.]*)\.scope\s*\(/g;
12
+ const RESOURCE = /^resource\s*:\s*/;
13
+ const TYPE = /\btype\s*:\s*(['"`])([\w-]+)\1/;
14
+ /**
15
+ * Under relationships, a requirement names the element its permission is checked on. A permission
16
+ * the relationship schema derives on an element type is not held on the context (the operators
17
+ * of the context do not have it): a requirement whose resource is `{ type: 'context' }` for it is
18
+ * refused at run time, or, if the project's bridge grants it widely, granted to everybody. Judged:
19
+ * the permissions the types other than `context` derive in the schema file of the platform, against
20
+ * the resource of every `@Requires`, `.requires(` and `requires(` outside the tests. What it cannot
21
+ * read is said, never taken as safe: a schema built by a call or spread, a key computed in another
22
+ * way, a resource that is not an object literal with a literal `type`.
23
+ */
24
+ export const authzResourceModelled = {
25
+ id: 'authz/resource-modelled',
26
+ description: 'Under relationships, a requirement names the element its permission is derived on in the relationship schema, never the context.',
27
+ scope: 'project',
28
+ run(project) {
29
+ const schemaFile = schemaOf(project);
30
+ return schemaFile === undefined ? [] : judged(project, schemaFile, reporter(project, this.id));
31
+ },
32
+ };
33
+ /** The relationship schema of the platform, when the project's rights are relationships and it holds one. */
34
+ function schemaOf(project) {
35
+ if (project.config.stack.authz !== 'rebac') {
36
+ return undefined;
37
+ }
38
+ const path = platformFileIn(project.config, 'auth/relationships/relationship-schema.ts', (candidate) => isInProject(project, candidate));
39
+ return project.files.find((file) => file.path === path);
40
+ }
41
+ function judged(project, schemaFile, report) {
42
+ const sources = project.files.filter((file) => !file.isTest && file.location.area === 'context');
43
+ const sets = sources.flatMap(permissionSets);
44
+ const schema = modelledPermissions(schemaFile, sets);
45
+ const searched = searchedPermissions(sources, sets);
46
+ const contextHolds = (id) => schema.contextHolds(id);
47
+ return [
48
+ ...schema.unread.map(({ line, what }) => report({ file: schemaFile.path, line }, `The checker cannot read the relationship schema: ${what}, so it cannot tell which permissions an element derives.`, "Write the types as an object literal given to defineSchema, the elements in an `elements` object of the file, and name each derived permission as `[<context>Permissions['<permission>'].id]` or by its id (`'<context>:<permission>'`).")),
49
+ ...sources.flatMap((file) => toViolations(report, file.path, unnamedElements(file, { sets, modelled: schema.modelled, searched, contextHolds }))),
50
+ ];
51
+ }
52
+ function unnamedElements(file, judged) {
53
+ const { code } = file.scan;
54
+ return [...code.matchAll(REQUIREMENT)].flatMap((call) => {
55
+ const parts = callArguments(code, call.index + call[0].length - 1);
56
+ return judgeRequirement(file, parts, { ...judged, line: file.scan.lineAt(call.index) });
57
+ });
58
+ }
59
+ function judgeRequirement(file, parts, judged) {
60
+ const { sets, modelled, searched, contextHolds, line } = judged;
61
+ const at = parts.findIndex((part) => scopedPermission(file, part, sets) !== undefined);
62
+ const permission = parts[at] === undefined ? undefined : scopedPermission(file, parts[at], sets);
63
+ if (permission === undefined) {
64
+ return [];
65
+ }
66
+ const id = `${permission.set.context}:${permission.key}`;
67
+ const type = modelled.find((entry) => entry.id === id)?.type;
68
+ if (type === undefined) {
69
+ return [];
70
+ }
71
+ const resource = resourceNamed(file, parts.slice(at + 1));
72
+ const naming = namingElement(permission.set.set, permission.key, type);
73
+ if (resource === undefined) {
74
+ return [{ line, message: unreadResource(id, type), fix: naming }];
75
+ }
76
+ if (resource !== 'context') {
77
+ return [];
78
+ }
79
+ if (searched.has(id) && contextHolds(id)) {
80
+ return [];
81
+ }
82
+ return [
83
+ searched.has(id) ? { line, ...sharedWithSearch(id, type) } : { line, message: onTheContext(id, type), fix: naming },
84
+ ];
85
+ }
86
+ /** The type the options of a requirement give its resource, undefined when they do not say it in a way the checker reads. */
87
+ function resourceNamed(file, rest) {
88
+ const options = rest.find(({ code }) => code.startsWith('{'));
89
+ return options === undefined ? undefined : resourceOf(file, options.start);
90
+ }
91
+ function onTheContext(id, type) {
92
+ return `${id} is checked on the context, but the relationship schema derives it on \`${type}\`: the rule on \`${type}\` is never asked, whoever holds the permission on the context passes.`;
93
+ }
94
+ function sharedWithSearch(id, type) {
95
+ return {
96
+ message: `${id} is checked on the context, and a search narrows by the same permission, which the schema derives on \`${type}\`: the operators of the context do not hold it, so the gate refuses everybody.`,
97
+ fix: `Use two permissions: this one, held on the context, to run the search (leave it out of the derived relations of \`${type}\`), and another, derived on \`${type}\`, for the scope (\`Access.scope(actor, <context>Permissions['<element>.view'], '${type}')\`).`,
98
+ };
99
+ }
100
+ function unreadResource(id, type) {
101
+ return `${id} is derived on \`${type}\` by the relationship schema, and the checker cannot read the resource of this requirement (it is not an object literal with a literal \`type\`), so it cannot tell whether it names \`${type}\`.`;
102
+ }
103
+ function namingElement(set, key, type) {
104
+ return `Name the ${type} in the requirement, \`@Requires(${set}['${key}'], { resource: (message) => ({ type: '${type}', id: message.${type}Id }) })\`, as an object literal with a literal \`type\`.`;
105
+ }
106
+ /** The type a requirement names: the literal `type` of its `resource`, undefined when it cannot be read. */
107
+ function resourceOf(file, open) {
108
+ const resource = callArguments(file.scan.code, open).find(({ code }) => RESOURCE.test(code));
109
+ if (resource === undefined) {
110
+ return undefined;
111
+ }
112
+ return TYPE.exec(file.text.slice(resource.start, resource.start + resource.code.length))?.[2];
113
+ }
114
+ /** The ids of the permissions a `.scope(` call of a handler narrows by. */
115
+ function searchedPermissions(sources, sets) {
116
+ const ids = new Set();
117
+ for (const file of sources) {
118
+ for (const call of file.scan.code.matchAll(SCOPE_CALL)) {
119
+ const argument = callArguments(file.scan.code, call.index + call[0].length - 1)[1];
120
+ const permission = argument === undefined ? undefined : scopedPermission(file, argument, sets);
121
+ if (permission !== undefined) {
122
+ ids.add(`${permission.set.context}:${permission.key}`);
123
+ }
124
+ }
125
+ }
126
+ return ids;
127
+ }
128
+ //# sourceMappingURL=authz-resource-modelled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authz-resource-modelled.js","sourceRoot":"","sources":["../../../src/check/rules/authz-resource-modelled.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAsB,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAO9D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,0GAA0G;AAC1G,MAAM,WAAW,GAAG,2CAA2C,CAAC;AAChE,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,IAAI,GAAG,gCAAgC,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAS;IACzC,EAAE,EAAE,yBAAyB;IAC7B,WAAW,EACT,kIAAkI;IAC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AI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,IAAI,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Rule } from '../model/rule.js';
2
+ export declare const schedulingTenancyDeclared: Rule;
3
+ //# sourceMappingURL=scheduling-tenancy-declared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduling-tenancy-declared.d.ts","sourceRoot":"","sources":["../../../src/check/rules/scheduling-tenancy-declared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAa1C,eAAO,MAAM,yBAAyB,EAAE,IAYvC,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { jobsDeclared } from '../scheduling/jobs-declared.js';
2
+ import { perFile } from '../support/per-file.js';
3
+ import { callArguments } from '../text/call-arguments.js';
4
+ const TENANCY_KEY = /^tenancy\s*:/;
5
+ const TENANCY_LITERAL = /^tenancy\s*:\s*(['"`])(?:global|per-tenant)\1$/;
6
+ const FIX = "Say it in the options of the job: `tenancy: 'per-tenant'` to run it once per tenant of the TenantDirectory, each run in the execution scope of that tenant (the default for a job that reads or writes tenant data), or `tenancy: 'global'` for work across tenants, which runs in no tenant and so reaches no tenant-scoped repository.";
7
+ export const schedulingTenancyDeclared = {
8
+ id: 'scheduling/tenancy-declared',
9
+ description: 'In a multi-tenant project ("stack.tenancy" other than "none"), a job states whether it runs per tenant or globally: `tenancy: \'per-tenant\'` or `tenancy: \'global\'` in the options of `@Scheduled(..)` and of `builder.job(..)`.',
10
+ scope: 'file',
11
+ run(project) {
12
+ if (project.config.stack.tenancy === 'none') {
13
+ return [];
14
+ }
15
+ return perFile(project, this.id, (file) => (file.isTest ? [] : undeclared(file)));
16
+ },
17
+ };
18
+ function undeclared(file) {
19
+ return jobsDeclared(file).flatMap(({ owner, line, args }) => {
20
+ const reading = tenancyOf(file, args[1]);
21
+ if (reading === 'declared') {
22
+ return [];
23
+ }
24
+ const what = reading === 'missing'
25
+ ? `The options given to ${owner} do not say whether the job runs per tenant or globally: without \`tenancy\` it runs globally, in no tenant, and a tenant-scoped repository refuses it at run time.`
26
+ : `The checker cannot read the \`tenancy\` option given to ${owner} (the options are not an object literal, spread another object, or give \`tenancy\` something other than a literal), so it cannot tell whether the job states it.`;
27
+ return [{ line, message: what, fix: FIX }];
28
+ });
29
+ }
30
+ /** What the options of a job say about its tenancy: a literal `global` or `per-tenant`, nothing, or something the checker cannot read. */
31
+ function tenancyOf(file, options) {
32
+ if (options === undefined || !options.code.startsWith('{')) {
33
+ return 'unread';
34
+ }
35
+ const members = callArguments(file.scan.code, options.start).map(({ start, code }) => file.text.slice(start, start + code.length));
36
+ if (members.some((member) => member.startsWith('...') || member.startsWith('['))) {
37
+ return 'unread';
38
+ }
39
+ const written = members.find((member) => TENANCY_KEY.test(member) || member === 'tenancy');
40
+ if (written === undefined) {
41
+ return 'missing';
42
+ }
43
+ return TENANCY_LITERAL.test(written) ? 'declared' : 'unread';
44
+ }
45
+ //# sourceMappingURL=scheduling-tenancy-declared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduling-tenancy-declared.js","sourceRoot":"","sources":["../../../src/check/rules/scheduling-tenancy-declared.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,MAAM,WAAW,GAAG,cAAc,CAAC;AACnC,MAAM,eAAe,GAAG,gDAAgD,CAAC;AAEzE,MAAM,GAAG,GACP,0UAA0U,CAAC;AAE7U,MAAM,CAAC,MAAM,yBAAyB,GAAS;IAC7C,EAAE,EA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CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,CACnF,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAC5C,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACjF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC;IAE3F,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/D,CAAC"}
@@ -7,6 +7,6 @@ export interface JobName {
7
7
  /** The name, when it is written as one string literal. */
8
8
  readonly literal: string | undefined;
9
9
  }
10
- /** The job names a source writes; `.job(..)` is read in a module file and in a file that imports `@ddd-ts-kit/di`. */
10
+ /** The job names a source writes. */
11
11
  export declare function jobNames(file: SourceFile): JobName[];
12
12
  //# sourceMappingURL=job-names.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"job-names.d.ts","sourceRoot":"","sources":["../../../src/check/scheduling/job-names.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOvD,+GAA+G;AAC/G,MAAM,WAAW,OAAO;IACtB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,sHAAsH;AACtH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,EAAE,CAkBpD"}
1
+ {"version":3,"file":"job-names.d.ts","sourceRoot":"","sources":["../../../src/check/scheduling/job-names.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,+GAA+G;AAC/G,MAAM,WAAW,OAAO;IACtB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,qCAAqC;AACrC,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,EAAE,CAEpD"}