saaslayer 0.4.2 → 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 +7 -7
- 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 +8 -3
- package/src/commands/stacks.js +2 -0
- package/src/commands/users-management.js +2 -2
- 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/src/users-import/ids.js +1 -1
- package/templates/saaslayer-foundation.yml +215 -281
- package/vendor/config/login-domain.js +213 -0
- package/vendor/discovery/index.d.mts +109 -0
- package/vendor/discovery/index.mjs +409 -0
- package/vendor/ids/index.d.ts +21 -0
- package/vendor/ids/index.js +237 -0
- package/vendor/migrations/backups.js +118 -0
- package/vendor/migrations/child.js +78 -0
- package/vendor/migrations/credentials.js +103 -0
- package/vendor/migrations/errors.js +30 -0
- package/vendor/migrations/exec-child.js +78 -0
- package/vendor/migrations/gate.js +51 -0
- package/vendor/migrations/index.js +30 -0
- package/vendor/migrations/inventory.js +92 -0
- package/vendor/migrations/log.js +14 -0
- package/vendor/migrations/release.js +45 -0
- package/vendor/migrations/report.js +129 -0
- package/vendor/migrations/rules.js +104 -0
- package/vendor/migrations/run.js +311 -0
- package/vendor/migrations/session-policy.js +37 -0
- package/vendor/migrations/step-guard.js +82 -0
- package/vendor/operations/activity.d.ts +21 -0
- package/vendor/operations/activity.js +126 -0
- package/vendor/operations/index.d.ts +72 -0
- package/vendor/operations/index.js +510 -0
- package/vendor/permissions-engine-core/account-status.js +270 -0
- package/vendor/permissions-engine-core/delegation.js +174 -0
- package/vendor/permissions-engine-core/direct-mode-contract.js +237 -0
- package/vendor/permissions-engine-core/sso-claims.js +206 -0
- package/vendor/user-management/cognito/emails/token-registry.js +48 -0
- package/vendor/user-management/email/validate.js +207 -0
- package/vendor/user-management/extensibility/hook-contract.js +720 -0
- package/vendor/user-management/extensibility/safe-webhook.js +85 -0
- package/vendor/user-management/identity/admission.js +215 -0
- package/vendor/user-management/identity/attr.js +27 -0
- package/vendor/user-management/identity/attribute-registry.js +115 -0
- package/vendor/user-management/identity/email.js +25 -0
- package/vendor/user-management/identity/ensure-suid.js +74 -0
- package/vendor/user-management/identity/pointers.js +192 -0
- package/vendor/user-management/identity/stitch-provider.js +275 -0
- package/vendor/user-management/management/apply-request.js +227 -0
- package/vendor/user-management/management/core-profile.js +110 -0
- package/vendor/user-management/management/index.js +23 -0
- package/vendor/user-management/management/purposes.js +94 -0
- package/vendor/user-management/management/registry.js +569 -0
- package/vendor/user-management/store/table.js +332 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// A deployment's activity feed: every change, who made it (customer or operator), the action, the reason and the
|
|
2
|
+
// operation it started. Entries come from deployer runs (a run is an operation) and from recorded non-run actions.
|
|
3
|
+
'use strict'
|
|
4
|
+
const { operationFromRun, redactText } = require('./index')
|
|
5
|
+
|
|
6
|
+
/** @typedef {'customer'|'operator'} ActorKind */
|
|
7
|
+
/** @typedef {{ kind: ActorKind, id: string }} Actor */
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} ActivityEntry
|
|
10
|
+
* @property {string} id the run id, or the recorded action's id
|
|
11
|
+
* @property {string|null} at
|
|
12
|
+
* @property {Actor|null} actor null when the change predates actor recording
|
|
13
|
+
* @property {string} action
|
|
14
|
+
* @property {string|null} subject the service or setting names the change touched (never values)
|
|
15
|
+
* @property {string|null} reason
|
|
16
|
+
* @property {string|null} operationId
|
|
17
|
+
* @property {string} [status] the operation status, for run entries
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const ACTOR_KINDS = ['customer', 'operator']
|
|
21
|
+
|
|
22
|
+
/** @param {unknown} v @returns {string|null} */
|
|
23
|
+
function str(v) {
|
|
24
|
+
return typeof v === 'string' && v ? v : null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** @param {unknown} v @returns {string[]} */
|
|
28
|
+
function strList(v) {
|
|
29
|
+
return Array.isArray(v) ? v.filter((x) => typeof x === 'string') : []
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A recorded actor, or null when it is missing or not a known kind.
|
|
34
|
+
* @param {unknown} value
|
|
35
|
+
* @returns {Actor|null}
|
|
36
|
+
*/
|
|
37
|
+
function actorOf(value) {
|
|
38
|
+
const a = /** @type {{ kind?: unknown, id?: unknown }} */ (value && typeof value === 'object' ? value : {})
|
|
39
|
+
return ACTOR_KINDS.includes(String(a.kind)) && str(a.id) ? { kind: /** @type {ActorKind} */ (a.kind), id: /** @type {string} */ (a.id) } : null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @param {unknown} v @returns {string|null} */
|
|
43
|
+
function reasonOf(v) {
|
|
44
|
+
return str(v) ? redactText(/** @type {string} */ (v)) : null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The setting names a run writes, as `service.Setting` (requestedSettings holds names only).
|
|
49
|
+
* @param {unknown} requestedSettings
|
|
50
|
+
* @returns {string[]}
|
|
51
|
+
*/
|
|
52
|
+
function settingNames(requestedSettings) {
|
|
53
|
+
const bySvc = requestedSettings && typeof requestedSettings === 'object' ? /** @type {Record<string, unknown>} */ (requestedSettings) : {}
|
|
54
|
+
return Object.entries(bySvc).flatMap(([svc, names]) => strList(names).map((n) => `${svc}.${n}`))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Project one deployer run as an activity entry. The run id is the operation id.
|
|
59
|
+
* @param {Record<string, unknown>} run
|
|
60
|
+
* @returns {ActivityEntry}
|
|
61
|
+
*/
|
|
62
|
+
function activityFromRun(run) {
|
|
63
|
+
const op = operationFromRun({ run })
|
|
64
|
+
const settings = settingNames(run.requestedSettings)
|
|
65
|
+
const isSettingsWrite = op.kind === 'deployment.update' && settings.length > 0
|
|
66
|
+
const isServiceChange = op.kind === 'service.add' || op.kind === 'service.remove'
|
|
67
|
+
const service = str(run.service) || strList(run.requestedServices)[0] || null
|
|
68
|
+
return {
|
|
69
|
+
id: op.id,
|
|
70
|
+
at: str(run.createdAt),
|
|
71
|
+
actor: actorOf(run.actor),
|
|
72
|
+
action: isSettingsWrite ? 'settings.update' : op.kind,
|
|
73
|
+
subject: isSettingsWrite ? settings.join(', ') : isServiceChange ? service : null,
|
|
74
|
+
reason: reasonOf(run.reason),
|
|
75
|
+
operationId: op.id,
|
|
76
|
+
status: op.status,
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Project a recorded non-run action (force unlock, cancel, transfer, ...) as an activity entry.
|
|
82
|
+
* @param {Record<string, unknown>} record
|
|
83
|
+
* @returns {ActivityEntry}
|
|
84
|
+
*/
|
|
85
|
+
function activityFromRecord(record) {
|
|
86
|
+
return {
|
|
87
|
+
id: String(record.activityId),
|
|
88
|
+
at: str(record.at),
|
|
89
|
+
actor: actorOf(record.actor),
|
|
90
|
+
action: String(record.action),
|
|
91
|
+
subject: str(record.subject),
|
|
92
|
+
reason: reasonOf(record.reason),
|
|
93
|
+
operationId: str(record.operationId),
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A deployment's activity, newest first.
|
|
99
|
+
* @param {{ runs?: Array<Record<string, unknown>>, records?: Array<Record<string, unknown>>, limit?: number }} input
|
|
100
|
+
* @returns {ActivityEntry[]}
|
|
101
|
+
*/
|
|
102
|
+
function activityFeed({ runs = [], records = [], limit }) {
|
|
103
|
+
const entries = [...runs.map(activityFromRun), ...records.map(activityFromRecord)]
|
|
104
|
+
entries.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')))
|
|
105
|
+
return typeof limit === 'number' && limit >= 0 ? entries.slice(0, limit) : entries
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* One line per entry: time, actor, action, subject, status, operation and reason.
|
|
110
|
+
* @param {ActivityEntry[]} entries
|
|
111
|
+
* @returns {string[]}
|
|
112
|
+
*/
|
|
113
|
+
function formatActivity(entries) {
|
|
114
|
+
if (entries.length === 0) return ['no activity']
|
|
115
|
+
return entries.map((e) => [
|
|
116
|
+
e.at || '-',
|
|
117
|
+
e.actor ? `${e.actor.kind}:${e.actor.id}` : 'unattributed',
|
|
118
|
+
e.action,
|
|
119
|
+
e.subject,
|
|
120
|
+
e.status,
|
|
121
|
+
e.operationId ? `op ${e.operationId}` : null,
|
|
122
|
+
e.reason ? JSON.stringify(e.reason) : null,
|
|
123
|
+
].filter(Boolean).join(' '))
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports = { ACTOR_KINDS, actorOf, activityFromRun, activityFromRecord, activityFeed, formatActivity }
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Types for @saaslayer/operations — the operation resource shared by control plane, services, CLI and console.
|
|
2
|
+
// Mirrors src/index.js (CommonJS, JSDoc-typed).
|
|
3
|
+
export type OperationStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'partial' | 'superseded'
|
|
4
|
+
export type ComponentStatus = 'pending' | 'running' | 'succeeded' | 'failed' | 'skipped' | 'unknown'
|
|
5
|
+
export interface OperationError { code?: string | null; message?: string | null }
|
|
6
|
+
export interface OperationComponent {
|
|
7
|
+
name: string
|
|
8
|
+
status: ComponentStatus
|
|
9
|
+
delivery?: 'external'
|
|
10
|
+
error?: OperationError
|
|
11
|
+
nextAction?: string
|
|
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[]
|
|
25
|
+
}
|
|
26
|
+
export interface Operation {
|
|
27
|
+
id: string
|
|
28
|
+
kind: string
|
|
29
|
+
status: OperationStatus
|
|
30
|
+
components: OperationComponent[]
|
|
31
|
+
createdAt: string | null
|
|
32
|
+
updatedAt: string | null
|
|
33
|
+
requestKey: string | null
|
|
34
|
+
deploymentId?: string
|
|
35
|
+
error?: OperationError
|
|
36
|
+
nextAction?: string
|
|
37
|
+
/** A delete destroy's or purge's report (ADR 0006 §5): complete, pending or incomplete, with what it removed and what remains. */
|
|
38
|
+
purgeResult?: Record<string, unknown>
|
|
39
|
+
}
|
|
40
|
+
export type IdempotencyDecision =
|
|
41
|
+
| { action: 'new' }
|
|
42
|
+
| { action: 'replay'; operationId: string | null }
|
|
43
|
+
| { action: 'conflict'; statusCode: 409; code: 'IDEMPOTENCY_KEY_REUSED'; error: string }
|
|
44
|
+
|
|
45
|
+
export const OPERATION_STATUSES: OperationStatus[]
|
|
46
|
+
export const COMPONENT_STATUSES: ComponentStatus[]
|
|
47
|
+
export const TERMINAL_STATUSES: OperationStatus[]
|
|
48
|
+
export const IDEMPOTENCY_RETENTION_SECONDS: number
|
|
49
|
+
export function isTerminal(status: string): boolean
|
|
50
|
+
export function createOperation(input: { id: string; kind: string; requestKey?: string | null; components?: Array<string | { name: string; delivery?: 'external' }>; now: string }): Operation
|
|
51
|
+
export function transition(op: Operation, next: string, now: string): Operation
|
|
52
|
+
export function rollupStatus(components: OperationComponent[]): OperationStatus
|
|
53
|
+
export function updateComponent(op: Operation, name: string, patch: { status: string; error?: OperationError; nextAction?: string }, now: string): Operation
|
|
54
|
+
export function fingerprint(payload: unknown): string
|
|
55
|
+
export function idempotencyScopeKey(input: { scope: string; kind: string; requestKey: string }): string
|
|
56
|
+
export function idempotencyExpiry(nowMs: number): number
|
|
57
|
+
export function resolveIdempotency(input: { record: Record<string, unknown> | null | undefined; fingerprint: string; nowMs: number }): IdempotencyDecision
|
|
58
|
+
export function operationFromRun(input: { deploymentId?: string; run: Record<string, unknown>; moduleResults?: Array<Record<string, unknown>> }): Operation
|
|
59
|
+
export function syncWriteResult<T>(input: { result: T; requestId: string; revision: number | string }): { result: T; requestId: string; revision: number | string }
|
|
60
|
+
export function redact<T>(value: T): T
|
|
61
|
+
export function redactText(text: string): string
|
|
62
|
+
export function operationLogLine(op: Operation, componentName?: string): string
|
|
63
|
+
export function formatOperation(op: Operation): string[]
|
|
64
|
+
export function watchOperation(input: {
|
|
65
|
+
id: string
|
|
66
|
+
fetchOperation: () => Promise<Operation>
|
|
67
|
+
sleep?: (ms: number) => Promise<void>
|
|
68
|
+
intervalMs?: number
|
|
69
|
+
maxConsecutiveErrors?: number
|
|
70
|
+
onUpdate?: (op: Operation) => void
|
|
71
|
+
resumeCommand?: string
|
|
72
|
+
}): Promise<Operation>
|