saaslayer 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/saaslayer.js +23 -11
- package/package.json +4 -3
- package/src/cdn-aws.js +67 -0
- package/src/cdn-publication.js +146 -0
- package/src/cdn-publisher.js +166 -0
- package/src/commands/cdn.js +66 -0
- package/src/commands/deploy.js +4 -3
- package/src/commands/lifecycle.js +20 -2
- package/src/commands/operations.js +7 -2
- package/src/commands/stacks.js +2 -0
- package/src/deployments.js +5 -2
- package/src/module-catalog.js +15 -5
- package/src/sms/scope.js +4 -2
- package/src/source-branch.js +36 -0
- package/templates/saaslayer-foundation.yml +215 -281
- package/vendor/operations/index.d.ts +13 -1
- package/vendor/operations/index.js +46 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Types for @saaslayer/operations — the operation resource shared by control plane, services, CLI and console.
|
|
2
2
|
// Mirrors src/index.js (CommonJS, JSDoc-typed).
|
|
3
|
-
export type OperationStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'partial'
|
|
3
|
+
export type OperationStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'partial' | 'superseded'
|
|
4
4
|
export type ComponentStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'skipped' | 'unknown'
|
|
5
5
|
export interface OperationError { code?: string | null; message?: string | null }
|
|
6
6
|
export interface OperationComponent {
|
|
@@ -10,6 +10,18 @@ export interface OperationComponent {
|
|
|
10
10
|
error?: OperationError
|
|
11
11
|
nextAction?: string
|
|
12
12
|
detail?: Record<string, unknown>
|
|
13
|
+
functionCode?: FunctionCode
|
|
14
|
+
/** How the deployment plan chose to apply this component. */
|
|
15
|
+
strategy?: Strategy
|
|
16
|
+
/** Why the plan chose that strategy (redacted). */
|
|
17
|
+
strategyReason?: string
|
|
18
|
+
}
|
|
19
|
+
export type Strategy = 'unchanged' | 'fullDeploy' | 'codeDeploy'
|
|
20
|
+
/** After a code-only update stopped partway: which functions run the requested, previous or unknown code. */
|
|
21
|
+
export interface FunctionCode {
|
|
22
|
+
updated: string[]
|
|
23
|
+
old: string[]
|
|
24
|
+
unknown: string[]
|
|
13
25
|
}
|
|
14
26
|
export interface Operation {
|
|
15
27
|
id: string
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// status (pending|running|succeeded|failed|partial), per-component outcomes, idempotency, redaction and watch.
|
|
3
3
|
'use strict'
|
|
4
4
|
|
|
5
|
-
/** @typedef {'pending'|'running'|'succeeded'|'failed'|'partial'} OperationStatus */
|
|
5
|
+
/** @typedef {'pending'|'running'|'succeeded'|'failed'|'partial'|'superseded'} OperationStatus */
|
|
6
6
|
/** @typedef {'pending'|'running'|'succeeded'|'failed'|'skipped'|'unknown'} ComponentStatus */
|
|
7
7
|
/** @typedef {{ code?: string|null, message?: string|null }} OperationError */
|
|
8
8
|
/**
|
|
@@ -13,6 +13,16 @@
|
|
|
13
13
|
* @property {OperationError} [error]
|
|
14
14
|
* @property {string} [nextAction] the next supported command for this component
|
|
15
15
|
* @property {Record<string, unknown>} [detail] the component's own reported state (redacted), e.g. a bootstrap's step
|
|
16
|
+
* @property {FunctionCode} [functionCode] after a code-only update stopped partway: which functions run which code
|
|
17
|
+
* @property {Strategy} [strategy] how the deployment plan chose to apply this component
|
|
18
|
+
* @property {string} [strategyReason] why the plan chose that strategy (redacted)
|
|
19
|
+
*/
|
|
20
|
+
/** @typedef {'unchanged'|'fullDeploy'|'codeDeploy'} Strategy */
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} FunctionCode
|
|
23
|
+
* @property {string[]} updated functions running the requested code
|
|
24
|
+
* @property {string[]} old functions provably still running the previous code
|
|
25
|
+
* @property {string[]} unknown functions whose code could not be determined
|
|
16
26
|
*/
|
|
17
27
|
/**
|
|
18
28
|
* @typedef {object} Operation
|
|
@@ -29,21 +39,25 @@
|
|
|
29
39
|
* @property {Record<string, unknown>} [purgeResult] a delete destroy's or purge's report: complete, pending or incomplete
|
|
30
40
|
*/
|
|
31
41
|
|
|
32
|
-
const OPERATION_STATUSES = ['pending', 'running', 'succeeded', 'failed', 'partial']
|
|
42
|
+
const OPERATION_STATUSES = ['pending', 'running', 'succeeded', 'failed', 'partial', 'superseded']
|
|
33
43
|
const COMPONENT_STATUSES = ['pending', 'running', 'succeeded', 'failed', 'skipped', 'unknown']
|
|
44
|
+
/** The plan strategies a component reports; any other planned value is left out. */
|
|
45
|
+
const STRATEGIES = ['unchanged', 'fullDeploy', 'codeDeploy']
|
|
34
46
|
const EXTERNAL_DELIVERY_STATUSES = ['pending', 'running', 'succeeded', 'failed', 'unknown']
|
|
35
|
-
|
|
47
|
+
// superseded: a waiting request replaced by a newer one before it started; it never ran
|
|
48
|
+
const TERMINAL_STATUSES = ['succeeded', 'failed', 'partial', 'superseded']
|
|
36
49
|
|
|
37
50
|
// How long a request key (and the operation it names) is replayable: 7 days. After that the key may be reused.
|
|
38
51
|
const IDEMPOTENCY_RETENTION_SECONDS = 7 * 24 * 60 * 60
|
|
39
52
|
|
|
40
53
|
/** @type {Record<string, OperationStatus[]>} */
|
|
41
54
|
const ALLOWED_TRANSITIONS = {
|
|
42
|
-
pending: ['running', 'succeeded', 'failed', 'partial'],
|
|
55
|
+
pending: ['running', 'succeeded', 'failed', 'partial', 'superseded'],
|
|
43
56
|
running: ['succeeded', 'failed', 'partial'],
|
|
44
57
|
succeeded: [],
|
|
45
58
|
failed: [],
|
|
46
59
|
partial: [],
|
|
60
|
+
superseded: [],
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
/** @param {string} status */
|
|
@@ -222,11 +236,25 @@ function loginDomainAction(run) {
|
|
|
222
236
|
return typeof action === 'string' && LOGIN_DOMAIN_ACTIONS.includes(action) ? action : null
|
|
223
237
|
}
|
|
224
238
|
|
|
239
|
+
/**
|
|
240
|
+
* A module result's per-function code report, or undefined when absent or malformed.
|
|
241
|
+
* @param {unknown} value
|
|
242
|
+
* @returns {FunctionCode|undefined}
|
|
243
|
+
*/
|
|
244
|
+
function functionCodeOf(value) {
|
|
245
|
+
if (!value || typeof value !== 'object') return undefined
|
|
246
|
+
const v = /** @type {Record<string, unknown>} */ (value)
|
|
247
|
+
const names = (/** @type {unknown} */ x) => Array.isArray(x) && x.every((n) => typeof n === 'string')
|
|
248
|
+
if (!names(v.updated) || !names(v.old) || !names(v.unknown)) return undefined
|
|
249
|
+
return { updated: [.../** @type {string[]} */ (v.updated)], old: [.../** @type {string[]} */ (v.old)], unknown: [.../** @type {string[]} */ (v.unknown)] }
|
|
250
|
+
}
|
|
251
|
+
|
|
225
252
|
/** @param {string|null|undefined} runStatus @returns {OperationStatus} */
|
|
226
253
|
function statusFromRun(runStatus) {
|
|
227
|
-
if (runStatus === 'QUEUED') return 'pending'
|
|
254
|
+
if (runStatus === 'QUEUED' || runStatus === 'WAITING') return 'pending'
|
|
228
255
|
if (runStatus === 'RUNNING' || runStatus === 'CANCEL_REQUESTED') return 'running'
|
|
229
256
|
if (runStatus === 'SUCCEEDED') return 'succeeded'
|
|
257
|
+
if (runStatus === 'SUPERSEDED') return 'superseded'
|
|
230
258
|
return 'failed'
|
|
231
259
|
}
|
|
232
260
|
|
|
@@ -294,7 +322,7 @@ function operationFromRun({ deploymentId, run, moduleResults = [] }) {
|
|
|
294
322
|
const result = resultByName.get(name)
|
|
295
323
|
const reported = result ? componentStatusFromResult(result) : null
|
|
296
324
|
/** @type {ComponentStatus} */
|
|
297
|
-
const status = reported || (runStatus === 'succeeded' ? 'succeeded' : runStatus === 'failed' ? 'unknown' : 'pending')
|
|
325
|
+
const status = reported || (runStatus === 'succeeded' ? 'succeeded' : runStatus === 'failed' ? 'unknown' : runStatus === 'superseded' ? 'skipped' : 'pending')
|
|
298
326
|
/** @type {OperationComponent} */
|
|
299
327
|
const component = { name: result && typeof result.component === 'string' ? result.component : name, status }
|
|
300
328
|
const error = result ? errorOf(result.errorCode, result.errorMessage) : undefined
|
|
@@ -302,6 +330,12 @@ function operationFromRun({ deploymentId, run, moduleResults = [] }) {
|
|
|
302
330
|
if (result && result.detail && typeof result.detail === 'object' && !Array.isArray(result.detail)) {
|
|
303
331
|
component.detail = /** @type {Record<string, unknown>} */ (redact(result.detail))
|
|
304
332
|
}
|
|
333
|
+
const functionCode = result ? functionCodeOf(result.functionCode) : undefined
|
|
334
|
+
if (functionCode) component.functionCode = functionCode
|
|
335
|
+
if (result && typeof result.strategy === 'string' && STRATEGIES.includes(result.strategy)) {
|
|
336
|
+
component.strategy = /** @type {Strategy} */ (result.strategy)
|
|
337
|
+
if (typeof result.strategyReason === 'string' && result.strategyReason) component.strategyReason = redactText(result.strategyReason)
|
|
338
|
+
}
|
|
305
339
|
if (status === 'failed') {
|
|
306
340
|
component.nextAction = nextActionFor({ kind, deploymentId, run, service: name, retryable: result && result.retryable !== undefined ? result.retryable : run.retryable, blocked: run.blocked })
|
|
307
341
|
}
|
|
@@ -404,7 +438,12 @@ function formatOperation(op) {
|
|
|
404
438
|
const width = Math.max(0, ...op.components.map((c) => c.name.length))
|
|
405
439
|
for (const c of op.components) {
|
|
406
440
|
const err = c.error ? ` ${[c.error.code, c.error.message].filter(Boolean).join(': ')}` : ''
|
|
407
|
-
|
|
441
|
+
const strategy = c.strategy ? ` ${[c.strategy, c.strategyReason].filter(Boolean).join(': ')}` : ''
|
|
442
|
+
lines.push(` ${c.name.padEnd(width)} ${c.status}${strategy}${err}`)
|
|
443
|
+
if (c.functionCode) {
|
|
444
|
+
const list = (/** @type {string[]} */ xs) => (xs.length ? xs.join(', ') : 'none')
|
|
445
|
+
lines.push(` ${''.padEnd(width)} functions updated: ${list(c.functionCode.updated)}; old: ${list(c.functionCode.old)}; unknown: ${list(c.functionCode.unknown)}`)
|
|
446
|
+
}
|
|
408
447
|
}
|
|
409
448
|
if (op.error && !op.components.some((c) => c.error)) lines.push(` error: ${[op.error.code, op.error.message].filter(Boolean).join(': ')}`)
|
|
410
449
|
const next = [...new Set([op.nextAction, ...op.components.map((c) => c.nextAction)].filter(Boolean))]
|