@ontemper/sdk 0.7.1-postgresql.2 → 0.7.1-postgresql.3
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/README.md +46 -2
- package/dist/As2Resource.d.ts +431 -76
- package/dist/As2Resource.d.ts.map +1 -1
- package/dist/As2Resource.js +31 -30
- package/dist/As2Resource.js.map +1 -1
- package/dist/As2Transport.d.ts.map +1 -1
- package/dist/As2Transport.js +3 -1
- package/dist/As2Transport.js.map +1 -1
- package/dist/As2Wire.d.ts +39 -0
- package/dist/As2Wire.d.ts.map +1 -1
- package/dist/DatabaseTunnelAuthorization.d.ts +11 -0
- package/dist/DatabaseTunnelAuthorization.d.ts.map +1 -0
- package/dist/DatabaseTunnelAuthorization.js +35 -0
- package/dist/DatabaseTunnelAuthorization.js.map +1 -0
- package/dist/ExpiringMap.d.ts +21 -0
- package/dist/ExpiringMap.d.ts.map +1 -0
- package/dist/ExpiringMap.js +79 -0
- package/dist/ExpiringMap.js.map +1 -0
- package/dist/HttpApiResource.d.ts +2904 -177
- package/dist/HttpApiResource.d.ts.map +1 -1
- package/dist/HttpApiResource.js +81 -59
- package/dist/HttpApiResource.js.map +1 -1
- package/dist/Kafka.d.ts +89 -0
- package/dist/Kafka.d.ts.map +1 -0
- package/dist/Kafka.js +297 -0
- package/dist/Kafka.js.map +1 -0
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.js +1 -1
- package/dist/PostgreSql.d.ts.map +1 -1
- package/dist/PostgreSql.js +2 -11
- package/dist/PostgreSql.js.map +1 -1
- package/dist/PostgreSqlPool.d.ts +1 -39
- package/dist/PostgreSqlPool.d.ts.map +1 -1
- package/dist/PostgreSqlPool.js +2 -22
- package/dist/PostgreSqlPool.js.map +1 -1
- package/dist/Redaction.d.ts +2 -0
- package/dist/Redaction.d.ts.map +1 -1
- package/dist/Redaction.js +16 -4
- package/dist/Redaction.js.map +1 -1
- package/dist/ResourceRecords.d.ts +1086 -0
- package/dist/ResourceRecords.d.ts.map +1 -0
- package/dist/ResourceRecords.js +303 -0
- package/dist/ResourceRecords.js.map +1 -0
- package/dist/Resources.d.ts +13 -3
- package/dist/Resources.d.ts.map +1 -1
- package/dist/Resources.js +11 -3
- package/dist/Resources.js.map +1 -1
- package/dist/ResourcesCache.d.ts +33 -0
- package/dist/ResourcesCache.d.ts.map +1 -0
- package/dist/ResourcesCache.js +205 -0
- package/dist/ResourcesCache.js.map +1 -0
- package/dist/ResourcesEnv.d.ts +81 -0
- package/dist/ResourcesEnv.d.ts.map +1 -0
- package/dist/ResourcesEnv.js +104 -0
- package/dist/ResourcesEnv.js.map +1 -0
- package/dist/ResourcesErrors.d.ts +5 -1
- package/dist/ResourcesErrors.d.ts.map +1 -1
- package/dist/ResourcesErrors.js +5 -2
- package/dist/ResourcesErrors.js.map +1 -1
- package/dist/ResourcesToken.d.ts +9 -0
- package/dist/ResourcesToken.d.ts.map +1 -1
- package/dist/ResourcesToken.js +20 -7
- package/dist/ResourcesToken.js.map +1 -1
- package/dist/RuntimeResources.d.ts +18 -3
- package/dist/RuntimeResources.d.ts.map +1 -1
- package/dist/RuntimeResources.js +53 -29
- package/dist/RuntimeResources.js.map +1 -1
- package/dist/TransportResource.d.ts +1 -32
- package/dist/TransportResource.d.ts.map +1 -1
- package/dist/TransportResource.js +1 -19
- package/dist/TransportResource.js.map +1 -1
- package/dist/Workflow.js +2 -2
- package/dist/Workflow.js.map +1 -1
- package/package.json +14 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceRecords.d.ts","sourceRoot":"","sources":["../src/ResourceRecords.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAuB,MAAM,EAAqD,MAAM,QAAQ,CAAC;AAYhH,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAK5D,mFAAmF;AACnF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC;AAC3C,MAAM,MAAM,U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'effect';
|
|
2
|
+
import { As2IdentityResource, As2PartnerResource } from './As2Resource.js';
|
|
3
|
+
import { AbsoluteHttpUrl, AwsAuth, HttpApiResource, HttpProxy, OAuthTokenRequest, recordStruct, TlsSettings, } from './HttpApiResource.js';
|
|
4
|
+
import { SDK_VERSION } from './Manifest.js';
|
|
5
|
+
import { InvalidResourceError } from './ResourcesErrors.js';
|
|
6
|
+
const Secret = Schema.RedactedFromValue(Schema.String);
|
|
7
|
+
const NonEmptySecret = Schema.RedactedFromValue(Schema.String.check(Schema.isMinLength(1)));
|
|
8
|
+
const NonEmptyString = Schema.String.check(Schema.isMinLength(1));
|
|
9
|
+
const Port = Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 }));
|
|
10
|
+
// Legacy SSH ports accept every integer, including those outside the safe-integer range and TCP port range.
|
|
11
|
+
const SshPort = Schema.Number.check(Schema.makeFilter(Number.isInteger, { expected: 'an integer', toJsonSchema: () => ({ type: 'integer' }) }));
|
|
12
|
+
const SshAlgorithms = recordStruct({
|
|
13
|
+
kex: Schema.optional(Schema.Array(Schema.String)),
|
|
14
|
+
serverHostKey: Schema.optional(Schema.Array(Schema.String)),
|
|
15
|
+
cipher: Schema.optional(Schema.Array(Schema.String)),
|
|
16
|
+
hmac: Schema.optional(Schema.Array(Schema.String)),
|
|
17
|
+
});
|
|
18
|
+
/** A `postgresql` record; `sslmode` carries libpq semantics, and `tls` the CA and client certificate. */
|
|
19
|
+
export const PostgresqlResource = recordStruct({
|
|
20
|
+
host: NonEmptyString,
|
|
21
|
+
port: Port.pipe(Schema.withDecodingDefault(Effect.succeed(5432))),
|
|
22
|
+
dbname: NonEmptyString,
|
|
23
|
+
user: NonEmptyString,
|
|
24
|
+
// Closed: the type decides how the client signs in.
|
|
25
|
+
auth: Schema.Union([
|
|
26
|
+
recordStruct({ type: Schema.Literal('password'), password: Secret }),
|
|
27
|
+
recordStruct({ type: Schema.Literal('rds_iam'), region: NonEmptyString, awsAuth: AwsAuth }),
|
|
28
|
+
recordStruct({ type: Schema.Literal('none') }),
|
|
29
|
+
]),
|
|
30
|
+
// Closed: libpq's weaker `allow` and `prefer` would map to no TLS at all.
|
|
31
|
+
sslmode: Schema.Literals(['disable', 'require', 'verify-ca', 'verify-full']).pipe(Schema.withDecodingDefault(Effect.succeed('verify-full'))),
|
|
32
|
+
tls: Schema.optional(TlsSettings),
|
|
33
|
+
sshTunnel: Schema.optional(recordStruct({
|
|
34
|
+
host: NonEmptyString,
|
|
35
|
+
port: SshPort.pipe(Schema.withDecodingDefault(Effect.succeed(22))),
|
|
36
|
+
username: Schema.String,
|
|
37
|
+
auth: Schema.Union([
|
|
38
|
+
recordStruct({
|
|
39
|
+
type: Schema.Literal('credentials'),
|
|
40
|
+
password: Schema.optional(Secret),
|
|
41
|
+
privateKey: Schema.optional(Secret),
|
|
42
|
+
passphrase: Schema.optional(Secret),
|
|
43
|
+
}),
|
|
44
|
+
]).pipe(Schema.withDecodingDefault(Effect.succeed({ type: 'credentials' }))),
|
|
45
|
+
hostKeyFingerprints: Schema.optional(Schema.Array(NonEmptyString)),
|
|
46
|
+
algorithms: Schema.optional(SshAlgorithms),
|
|
47
|
+
})),
|
|
48
|
+
options: Schema.optional(Schema.String),
|
|
49
|
+
});
|
|
50
|
+
// The port is 1-65535 without leading zeros, as the API catalog requires; `\s` is spelled out for deploy's RE2.
|
|
51
|
+
const KafkaBroker = Schema.String.check(Schema.isPattern(/^(\[[0-9A-Fa-f:.]+\]|[^\t\n\v\f\r\p{Z}:/@[\]]+):(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/u), Schema.makeFilter((broker) => !broker.includes(String.fromCodePoint(0xfeff)), {
|
|
52
|
+
expected: 'a broker without whitespace',
|
|
53
|
+
toJsonSchema: () => ({ not: { pattern: String.fromCodePoint(0xfeff) } }),
|
|
54
|
+
}));
|
|
55
|
+
const KafkaAuth = Schema.Union([
|
|
56
|
+
recordStruct({ type: Schema.Literal('none') }),
|
|
57
|
+
recordStruct({ type: Schema.Literal('sasl_plain'), username: Schema.String, password: Secret }),
|
|
58
|
+
recordStruct({
|
|
59
|
+
type: Schema.Literal('sasl_scram'),
|
|
60
|
+
mechanism: Schema.Literals(['SCRAM-SHA-256', 'SCRAM-SHA-512']).pipe(Schema.withDecodingDefault(Effect.succeed('SCRAM-SHA-512'))),
|
|
61
|
+
username: Schema.String,
|
|
62
|
+
password: Secret,
|
|
63
|
+
}),
|
|
64
|
+
recordStruct({ type: Schema.Literal('oauthbearer'), tokenRequest: OAuthTokenRequest }),
|
|
65
|
+
recordStruct({ type: Schema.Literal('aws_msk_iam'), region: NonEmptyString, awsAuth: AwsAuth }),
|
|
66
|
+
]);
|
|
67
|
+
/** A `kafka` record: bootstrap brokers, the `auth` variant, and `tls`, whose presence turns TLS on. */
|
|
68
|
+
export const KafkaResource = recordStruct({
|
|
69
|
+
brokers: Schema.Array(KafkaBroker).check(Schema.isMinLength(1)),
|
|
70
|
+
clientId: Schema.optional(Schema.String),
|
|
71
|
+
// Closed: the type decides the SASL mechanism, and a client that falls back on an unknown one signs in without it.
|
|
72
|
+
auth: KafkaAuth,
|
|
73
|
+
tls: Schema.optional(TlsSettings),
|
|
74
|
+
}).check(
|
|
75
|
+
// MSK IAM and OAuth bearer send a token in the SASL payload; without `tls` it would cross the network in plaintext.
|
|
76
|
+
Schema.makeFilter(({ auth, tls }) => (auth.type !== 'aws_msk_iam' && auth.type !== 'oauthbearer') ||
|
|
77
|
+
tls !== undefined || { path: ['tls'], issue: 'Expected tls with aws_msk_iam or oauthbearer' }));
|
|
78
|
+
/** An `s3` record: bucket, region, an optional S3-compatible endpoint, and the AWS credential source under `auth`. */
|
|
79
|
+
export const S3Resource = recordStruct({
|
|
80
|
+
bucket: NonEmptyString,
|
|
81
|
+
region: NonEmptyString.pipe(Schema.withDecodingDefault(Effect.succeed('us-east-1'))),
|
|
82
|
+
endpoint: Schema.optional(AbsoluteHttpUrl),
|
|
83
|
+
pathStyle: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
|
84
|
+
prefix: Schema.optional(Schema.String),
|
|
85
|
+
// Closed and required: `ambient` is an explicit choice (Temper-operated runtimes refuse it), never a fallback.
|
|
86
|
+
auth: AwsAuth,
|
|
87
|
+
tls: Schema.optional(TlsSettings),
|
|
88
|
+
proxy: Schema.optional(HttpProxy),
|
|
89
|
+
});
|
|
90
|
+
// Closed: the type decides which identity the client presents, and a guess could fall back to anonymous access.
|
|
91
|
+
const AzureAuth = Schema.Union([
|
|
92
|
+
recordStruct({ type: Schema.Literal('shared_key'), accountKey: NonEmptySecret }),
|
|
93
|
+
recordStruct({ type: Schema.Literal('sas'), sasToken: NonEmptySecret }),
|
|
94
|
+
recordStruct({
|
|
95
|
+
type: Schema.Literal('service_principal'),
|
|
96
|
+
tenantId: NonEmptyString,
|
|
97
|
+
clientId: NonEmptyString,
|
|
98
|
+
clientSecret: NonEmptySecret,
|
|
99
|
+
}),
|
|
100
|
+
recordStruct({
|
|
101
|
+
type: Schema.Literal('service_principal_certificate'),
|
|
102
|
+
tenantId: NonEmptyString,
|
|
103
|
+
clientId: NonEmptyString,
|
|
104
|
+
certificatePem: NonEmptySecret,
|
|
105
|
+
}),
|
|
106
|
+
recordStruct({ type: Schema.Literal('ambient') }),
|
|
107
|
+
]);
|
|
108
|
+
/** An `azure_blob` record: account, container, endpoint, and the credential source under `auth`. */
|
|
109
|
+
export const AzureBlobResource = recordStruct({
|
|
110
|
+
accountName: NonEmptyString,
|
|
111
|
+
containerName: NonEmptyString,
|
|
112
|
+
// A full Blob service URL (Azurite, a gateway, a custom domain); it overrides `endpointSuffix`.
|
|
113
|
+
endpoint: Schema.optional(AbsoluteHttpUrl),
|
|
114
|
+
endpointSuffix: NonEmptyString.pipe(Schema.withDecodingDefault(Effect.succeed('core.windows.net'))),
|
|
115
|
+
prefix: Schema.optional(Schema.String),
|
|
116
|
+
auth: AzureAuth,
|
|
117
|
+
tls: Schema.optional(TlsSettings),
|
|
118
|
+
proxy: Schema.optional(HttpProxy),
|
|
119
|
+
});
|
|
120
|
+
const sftpFields = {
|
|
121
|
+
host: NonEmptyString,
|
|
122
|
+
port: SshPort.pipe(Schema.withDecodingDefault(Effect.succeed(22))),
|
|
123
|
+
username: NonEmptyString,
|
|
124
|
+
// Closed: the type decides which credentials the client offers.
|
|
125
|
+
auth: Schema.Union([
|
|
126
|
+
recordStruct({ type: Schema.Literal('password'), password: Secret }),
|
|
127
|
+
recordStruct({
|
|
128
|
+
type: Schema.Literal('private_key'),
|
|
129
|
+
privateKey: Secret,
|
|
130
|
+
passphrase: Schema.optional(Secret),
|
|
131
|
+
}),
|
|
132
|
+
recordStruct({
|
|
133
|
+
type: Schema.Literal('private_key_and_password'),
|
|
134
|
+
privateKey: Secret,
|
|
135
|
+
passphrase: Schema.optional(Secret),
|
|
136
|
+
password: Secret,
|
|
137
|
+
}),
|
|
138
|
+
]),
|
|
139
|
+
hostKeyFingerprints: Schema.optional(Schema.Array(NonEmptyString)),
|
|
140
|
+
algorithms: Schema.optional(SshAlgorithms),
|
|
141
|
+
};
|
|
142
|
+
const SftpLifted = Schema.toType(recordStruct({
|
|
143
|
+
...sftpFields,
|
|
144
|
+
password: Schema.optional(Schema.Redacted(Schema.Unknown)),
|
|
145
|
+
privateKey: Schema.optional(Schema.Redacted(Schema.Unknown)),
|
|
146
|
+
passphrase: Schema.optional(Schema.Redacted(Schema.Unknown)),
|
|
147
|
+
}));
|
|
148
|
+
/**
|
|
149
|
+
* An `sftp` record; `hostKeyFingerprints` are the `SHA256:` fingerprints the client must pin when set. The
|
|
150
|
+
* credentials under `auth` are also lifted to the top level. Lifted values are Redacted<unknown>: legacy also copies
|
|
151
|
+
* undeclared credential fields; narrow those values before use, or read the typed fields of the auth variant.
|
|
152
|
+
*/
|
|
153
|
+
export const SftpResource = recordStruct(sftpFields).pipe(Schema.decodeTo(SftpLifted, SchemaTransformation.transform({
|
|
154
|
+
decode: (record) => {
|
|
155
|
+
const lifted = {};
|
|
156
|
+
for (const field of ['password', 'privateKey', 'passphrase']) {
|
|
157
|
+
const value = record.auth[field];
|
|
158
|
+
if (value !== undefined)
|
|
159
|
+
lifted[field] = Redacted.isRedacted(value) ? value : Redacted.make(value);
|
|
160
|
+
}
|
|
161
|
+
// Legacy lifting overwrites root credential copies, including stale fields the auth variant does not use.
|
|
162
|
+
const { password: _password, privateKey: _privateKey, passphrase: _passphrase, ...fields } = record;
|
|
163
|
+
return { ...fields, ...lifted };
|
|
164
|
+
},
|
|
165
|
+
encode: ({ password: _password, privateKey: _privateKey, passphrase: _passphrase, ...record }) => record,
|
|
166
|
+
})));
|
|
167
|
+
const CLIENT_NAME = '@ontemper/sdk';
|
|
168
|
+
/**
|
|
169
|
+
* A built-in record holds a value this SDK does not know in a closed field: one that chooses TLS, where a key
|
|
170
|
+
* travels, or AS2 cryptography, where a guess would weaken security silently. The message names the fields and this
|
|
171
|
+
* SDK's version, never the value, which can be a mis-pointed secret.
|
|
172
|
+
*/
|
|
173
|
+
export class UnknownRecordValueError extends Schema.TaggedError()('UnknownRecordValueError', {
|
|
174
|
+
key: Schema.String,
|
|
175
|
+
fields: Schema.Array(Schema.String),
|
|
176
|
+
clientVersion: Schema.String,
|
|
177
|
+
message: Schema.String,
|
|
178
|
+
}) {
|
|
179
|
+
static of(key, fields) {
|
|
180
|
+
const subject = fields.length === 1 ? `field ${fields[0]} uses a value` : `fields ${fields.join(', ')} use values`;
|
|
181
|
+
return new UnknownRecordValueError({
|
|
182
|
+
key,
|
|
183
|
+
fields,
|
|
184
|
+
clientVersion: SDK_VERSION,
|
|
185
|
+
message: `record ${key}: ${subject} this ${CLIENT_NAME} version (${SDK_VERSION}) does not know; ` +
|
|
186
|
+
'upgrade to a release that supports it',
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Only these schemas mirror the platform catalog; a caller's own closed value failing is not an outdated SDK.
|
|
191
|
+
const BUILT_IN_RECORDS = new Set([
|
|
192
|
+
HttpApiResource,
|
|
193
|
+
SftpResource,
|
|
194
|
+
PostgresqlResource,
|
|
195
|
+
KafkaResource,
|
|
196
|
+
S3Resource,
|
|
197
|
+
AzureBlobResource,
|
|
198
|
+
As2IdentityResource,
|
|
199
|
+
As2PartnerResource,
|
|
200
|
+
]);
|
|
201
|
+
const isJsonObject = Schema.is(Schema.JsonObject);
|
|
202
|
+
const isJsonArray = Schema.is(Schema.Array(Schema.Json));
|
|
203
|
+
// The resolved value at an issue's path; closed values sit in objects, and arrays only hold brokers and fingerprints.
|
|
204
|
+
const valueAt = (value, path) => path.reduce((current, segment) => {
|
|
205
|
+
if (isJsonArray(current))
|
|
206
|
+
return current[Number(segment)];
|
|
207
|
+
return isJsonObject(current) ? current[segment] : undefined;
|
|
208
|
+
}, value);
|
|
209
|
+
// The one property every member of a union of structs fixes to a literal, such as `type` or `mode`.
|
|
210
|
+
const discriminatorOf = (types) => {
|
|
211
|
+
const literalKeys = (ast) => SchemaAST.isObjects(ast)
|
|
212
|
+
? ast.propertySignatures.filter((field) => SchemaAST.isLiteral(field.type)).map((field) => String(field.name))
|
|
213
|
+
: [];
|
|
214
|
+
const [first, ...rest] = types;
|
|
215
|
+
if (first === undefined)
|
|
216
|
+
return undefined;
|
|
217
|
+
return literalKeys(first).find((key) => rest.every((member) => literalKeys(member).includes(key)));
|
|
218
|
+
};
|
|
219
|
+
// Never the received value: a secret mis-pointed at the field would land in the error.
|
|
220
|
+
const leafMessage = (issue) => {
|
|
221
|
+
if (issue._tag === 'MissingKey')
|
|
222
|
+
return 'Missing key';
|
|
223
|
+
const invalid = issue._tag === 'Filter' ? issue.issue : issue;
|
|
224
|
+
const message = invalid._tag === 'InvalidValue' ? invalid.annotations?.message : undefined;
|
|
225
|
+
if (Predicate.isString(message))
|
|
226
|
+
return message;
|
|
227
|
+
const expected = issue._tag === 'Filter' ? issue.filter.annotations?.expected : undefined;
|
|
228
|
+
return Predicate.isString(expected) ? `Expected ${expected}` : 'Invalid value';
|
|
229
|
+
};
|
|
230
|
+
const unionFindings = (union, path, value) => {
|
|
231
|
+
if (!SchemaAST.isUnion(union))
|
|
232
|
+
return [{ path, message: 'Invalid value', unknownValue: false }];
|
|
233
|
+
const types = union.types.filter((member) => !SchemaAST.isUndefined(member));
|
|
234
|
+
const only = types[0];
|
|
235
|
+
if (types.length === 1 && only !== undefined && SchemaAST.isUnion(only))
|
|
236
|
+
return unionFindings(only, path, value);
|
|
237
|
+
const at = valueAt(value, path);
|
|
238
|
+
if (types.every(SchemaAST.isLiteral)) {
|
|
239
|
+
return [{ path, message: 'Invalid value', unknownValue: Predicate.isString(at) }];
|
|
240
|
+
}
|
|
241
|
+
const discriminator = discriminatorOf(types);
|
|
242
|
+
if (discriminator === undefined || !isJsonObject(at))
|
|
243
|
+
return [{ path, message: 'Invalid value', unknownValue: false }];
|
|
244
|
+
const received = at[discriminator];
|
|
245
|
+
return [
|
|
246
|
+
{
|
|
247
|
+
path: [...path, discriminator],
|
|
248
|
+
message: received === undefined ? 'Missing key' : 'Invalid value',
|
|
249
|
+
unknownValue: Predicate.isString(received),
|
|
250
|
+
},
|
|
251
|
+
];
|
|
252
|
+
};
|
|
253
|
+
function findings(issue, path, value) {
|
|
254
|
+
switch (issue._tag) {
|
|
255
|
+
case 'Pointer':
|
|
256
|
+
return findings(issue.issue, [...path, ...issue.path.map(String)], value);
|
|
257
|
+
case 'Composite':
|
|
258
|
+
return issue.issues.flatMap((inner) => findings(inner, path, value));
|
|
259
|
+
case 'Encoding':
|
|
260
|
+
return findings(issue.issue, path, value);
|
|
261
|
+
case 'Filter':
|
|
262
|
+
// A filter that names a field (`{ path, issue }`) reports at that field.
|
|
263
|
+
return issue.issue._tag === 'Pointer'
|
|
264
|
+
? findings(issue.issue, path, value)
|
|
265
|
+
: [{ path, message: leafMessage(issue), unknownValue: false }];
|
|
266
|
+
case 'AnyOf': {
|
|
267
|
+
if (issue.issues.length === 0)
|
|
268
|
+
return unionFindings(issue.ast, path, value);
|
|
269
|
+
const candidates = issue.issues.map((inner) => findings(inner, path, value));
|
|
270
|
+
// A catch-all member that fails only at `type` (`HttpApiAuth`'s unsupported variant) is not the intended one.
|
|
271
|
+
const intended = candidates.filter((found) => !found.every((finding) => finding.path.length === path.length + 1 && finding.path.at(-1) === 'type'));
|
|
272
|
+
return (intended.length > 0 ? intended : candidates).flat();
|
|
273
|
+
}
|
|
274
|
+
default:
|
|
275
|
+
return [{ path, message: leafMessage(issue), unknownValue: false }];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const PATTERN_MESSAGE = 'Expected a string matching the RegExp';
|
|
279
|
+
/**
|
|
280
|
+
* Decodes a resolved record. A mismatch names the fields, never their values; a built-in record with a closed value
|
|
281
|
+
* this SDK does not know fails with `UnknownRecordValueError`.
|
|
282
|
+
*/
|
|
283
|
+
export const decodeRecord = (schema, key, value) => Schema.decodeUnknownEffect(schema)(value, { errors: 'all' }).pipe(Effect.mapError((error) => {
|
|
284
|
+
const found = findings(error.issue, [], value);
|
|
285
|
+
const unknown = [
|
|
286
|
+
...new Set(found.filter((finding) => finding.unknownValue).map((finding) => finding.path.join('.'))),
|
|
287
|
+
];
|
|
288
|
+
if (BUILT_IN_RECORDS.has(schema) && unknown.length > 0)
|
|
289
|
+
return UnknownRecordValueError.of(key, unknown);
|
|
290
|
+
const lines = found.map((finding) => ({
|
|
291
|
+
field: finding.path.join('.') || '<root>',
|
|
292
|
+
message: finding.message,
|
|
293
|
+
}));
|
|
294
|
+
// Overlapping patterns and custom checks can fail together; the custom message says why.
|
|
295
|
+
const shown = lines.filter(({ field, message }) => !message.startsWith(PATTERN_MESSAGE) ||
|
|
296
|
+
!lines.some((other) => other.field === field && !other.message.startsWith(PATTERN_MESSAGE)));
|
|
297
|
+
const issues = [...new Set(shown.map(({ field, message }) => `${field}: ${message}`))];
|
|
298
|
+
return new InvalidResourceError({
|
|
299
|
+
target: `key ${key}`,
|
|
300
|
+
message: `Resource ${key} does not match the expected schema: ${issues.join('; ')}`,
|
|
301
|
+
});
|
|
302
|
+
}));
|
|
303
|
+
//# sourceMappingURL=ResourceRecords.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceRecords.js","sourceRoot":"","sources":["../src/ResourceRecords.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAoB,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAChH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EACL,eAAe,EACf,OAAO,EACP,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAS5D,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,cAAc,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5F,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AACjF,4GAA4G;AAC5G,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACjC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,EA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,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IACvF,OAAO,IAAI,oBAAoB,CAAC;QAC9B,MAAM,EAAE,OAAO,GAAG,EAAE;QACpB,OAAO,EAAE,YAAY,GAAG,wCAAwC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;KACpF,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC"}
|
package/dist/Resources.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Resource readers, records, Kafka client options, and a promise-style `env` for code outside Effect:
|
|
3
|
+
* `import { makePostgresqlPool, KafkaResource, kafkaConfig } from '@temper/workflow/resources'`. The surface of
|
|
4
|
+
* `@ontemper/resources` without its partner and connection state. PostgreSQL pools load the optional `pg` and `ws`
|
|
5
|
+
* peers when a pool is built, and Kafka's optional AWS peers load only for MSK IAM, so importing this module needs none.
|
|
4
6
|
*/
|
|
5
|
-
export {
|
|
7
|
+
export { As2IdentityResource, As2PartnerResource } from './As2Resource.js';
|
|
8
|
+
export { getDatabaseTunnelAuthorization } from './DatabaseTunnelAuthorization.js';
|
|
9
|
+
export { HttpApiAuth, HttpApiResource, HttpApiUnsupportedAuth, HttpProxy, OAuthTokenRequest, TlsSettings, } from './HttpApiResource.js';
|
|
10
|
+
export { createPostgresqlPool, makePostgresqlPool, type PostgresqlPoolError } from './PostgreSql.js';
|
|
11
|
+
/** A resolved Variable value; the root's `Variable` export is the Effect declaration instead. */
|
|
12
|
+
export type Variable = string;
|
|
13
|
+
export { AzureBlobResource, type JsonObject, type JsonValue, KafkaResource, PostgresqlResource, S3Resource, SftpResource, UnknownRecordValueError, } from './ResourceRecords.js';
|
|
14
|
+
export { kafkaConfig, type KafkaClientConfig, type KafkaClientSasl, type KafkaClientTlsOptions, type KafkaConfigOptions, OptionalKafkaDependencyError, UnsupportedKafkaAuthError, } from './Kafka.js';
|
|
15
|
+
export { env, type RuntimeEnv, type RuntimeEnvConfig, type RuntimeEnvLogger, type RuntimeResourceReads, type RuntimeVariableReads, type RuntimeResolveOptions, type RuntimeResourceRecord, type RuntimeSelectResourceInput, type RuntimeSelectResourceOutput, } from './ResourcesEnv.js';
|
|
6
16
|
export { InvalidResourceError, ResourceNotFoundError, ResourceNotSelectableError, ResourcesUnauthorizedError, ResourcesUnavailableError, } from './ResourcesErrors.js';
|
|
7
17
|
//# sourceMappingURL=Resources.d.ts.map
|
package/dist/Resources.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resources.d.ts","sourceRoot":"","sources":["../src/Resources.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Resources.d.ts","sourceRoot":"","sources":["../src/Resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAErG,iGAAiG;AACjG,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC9B,OAAO,EACL,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,GAAG,EACH,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,GACjC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC"}
|
package/dist/Resources.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Resource readers, records, Kafka client options, and a promise-style `env` for code outside Effect:
|
|
3
|
+
* `import { makePostgresqlPool, KafkaResource, kafkaConfig } from '@temper/workflow/resources'`. The surface of
|
|
4
|
+
* `@ontemper/resources` without its partner and connection state. PostgreSQL pools load the optional `pg` and `ws`
|
|
5
|
+
* peers when a pool is built, and Kafka's optional AWS peers load only for MSK IAM, so importing this module needs none.
|
|
4
6
|
*/
|
|
5
|
-
export {
|
|
7
|
+
export { As2IdentityResource, As2PartnerResource } from './As2Resource.js';
|
|
8
|
+
export { getDatabaseTunnelAuthorization } from './DatabaseTunnelAuthorization.js';
|
|
9
|
+
export { HttpApiAuth, HttpApiResource, HttpApiUnsupportedAuth, HttpProxy, OAuthTokenRequest, TlsSettings, } from './HttpApiResource.js';
|
|
10
|
+
export { createPostgresqlPool, makePostgresqlPool } from './PostgreSql.js';
|
|
11
|
+
export { AzureBlobResource, KafkaResource, PostgresqlResource, S3Resource, SftpResource, UnknownRecordValueError, } from './ResourceRecords.js';
|
|
12
|
+
export { kafkaConfig, OptionalKafkaDependencyError, UnsupportedKafkaAuthError, } from './Kafka.js';
|
|
13
|
+
export { env, } from './ResourcesEnv.js';
|
|
6
14
|
export { InvalidResourceError, ResourceNotFoundError, ResourceNotSelectableError, ResourcesUnauthorizedError, ResourcesUnavailableError, } from './ResourcesErrors.js';
|
|
7
15
|
//# sourceMappingURL=Resources.js.map
|
package/dist/Resources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resources.js","sourceRoot":"","sources":["../src/Resources.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Resources.js","sourceRoot":"","sources":["../src/Resources.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAA4B,MAAM,iBAAiB,CAAC;AAIrG,OAAO,EACL,iBAAiB,EAGjB,aAAa,EACb,kBAAkB,EAClB,UAAU,EACV,YAAY,EACZ,uBAAuB,GACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,WAAW,EAKX,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,GAAG,GAUJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Schema } from 'effect';
|
|
2
|
+
import type { RuntimeEnvConfig, RuntimeEnvLogger, RuntimeResolveOptions } from './ResourcesEnv.js';
|
|
3
|
+
export interface CachePolicy {
|
|
4
|
+
readonly staleIfErrorMs: number;
|
|
5
|
+
readonly cacheMisses: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** The legacy resolver cache, keyed by operation and target; every caller gets its own copy of a value. */
|
|
8
|
+
export declare class RuntimeReadCache {
|
|
9
|
+
private readonly values;
|
|
10
|
+
private readonly misses;
|
|
11
|
+
private readonly inFlight;
|
|
12
|
+
private readonly defaultTtlMs;
|
|
13
|
+
readonly readPolicy: CachePolicy;
|
|
14
|
+
readonly selectPolicy: CachePolicy;
|
|
15
|
+
private readonly notFoundTtlMs;
|
|
16
|
+
private readonly missCapPerMinute;
|
|
17
|
+
private missWindowStart;
|
|
18
|
+
private readonly missedInWindow;
|
|
19
|
+
private holdingMisses;
|
|
20
|
+
private generation;
|
|
21
|
+
private readonly now;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
constructor(config: RuntimeEnvConfig & {
|
|
24
|
+
readonly logger: RuntimeEnvLogger;
|
|
25
|
+
});
|
|
26
|
+
read<A extends Schema.Json>(target: string, options: RuntimeResolveOptions | undefined, policy: CachePolicy, fetch: () => Promise<A>): Promise<A>;
|
|
27
|
+
private nextGeneration;
|
|
28
|
+
private rollMissWindow;
|
|
29
|
+
private recordConfirmedMiss;
|
|
30
|
+
private invalidate;
|
|
31
|
+
private load;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ResourcesCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourcesCache.d.ts","sourceRoot":"","sources":["../src/ResourcesCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAsCnG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAmBD,2GAA2G;AAC3G,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IAEjD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmC;IAC5D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,eAAe,CAA4B;IAEnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAqB;IAGpD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAE1C,YAAY,MAAM,EAAE,gBAAgB,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;KAAE,EA2B3E;IAEK,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,IAAI,EAC9B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,qBAAqB,GAAG,SAAS,EAC1C,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACtB,OAAO,CAAC,CAAC,CAAC,CA6CZ;IAED,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,mBAAmB;IAsB3B,OAAO,CAAC,UAAU;YAaJ,IAAI;CAyCnB"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import {} from 'effect';
|
|
2
|
+
import { ExpiringMap } from './ExpiringMap.js';
|
|
3
|
+
import { ResourceNotFoundError, ResourcesUnauthorizedError, ResourcesUnavailableError } from './ResourcesErrors.js';
|
|
4
|
+
import { TOKEN_NOT_PUBLISHED } from './ResourcesToken.js';
|
|
5
|
+
const DEFAULT_TTL_MS = 30_000;
|
|
6
|
+
const DEFAULT_STALE_IF_ERROR_MS = 15 * 60_000;
|
|
7
|
+
const DEFAULT_SELECT_STALE_IF_ERROR_MS = 5 * 60_000;
|
|
8
|
+
const DEFAULT_NOT_FOUND_TTL_MS = 10_000;
|
|
9
|
+
// One tenant costs a select, a resolve, and its Variables, so 1,000 entries held only ~450 tenants per process.
|
|
10
|
+
const DEFAULT_MAX_ENTRIES = 10_000;
|
|
11
|
+
const DEFAULT_MISS_CAP_PER_MINUTE = 60;
|
|
12
|
+
const MISS_WINDOW_MS = 60_000;
|
|
13
|
+
const RETRY_AFTER_UNAVAILABLE_MS = 5_000;
|
|
14
|
+
const readEnvInteger = (name, fallback, min) => {
|
|
15
|
+
const raw = process.env[name];
|
|
16
|
+
if (!raw)
|
|
17
|
+
return fallback;
|
|
18
|
+
const value = Number(raw);
|
|
19
|
+
return Number.isSafeInteger(value) && value >= min ? value : fallback;
|
|
20
|
+
};
|
|
21
|
+
// No usable answer: a transport fault, a timeout, a 5xx, or a token provider that stopped publishing (an API outage).
|
|
22
|
+
// An undeclared 4xx carries its status: it is an answer, so it drops the cached value instead of serving it stale.
|
|
23
|
+
const isOutage = (error) => (error instanceof ResourcesUnavailableError &&
|
|
24
|
+
(error.status === undefined || error.status >= 500 || error.status < 400)) ||
|
|
25
|
+
(error instanceof ResourcesUnauthorizedError && error.message === TOKEN_NOT_PUBLISHED);
|
|
26
|
+
/** The legacy resolver cache, keyed by operation and target; every caller gets its own copy of a value. */
|
|
27
|
+
export class RuntimeReadCache {
|
|
28
|
+
values;
|
|
29
|
+
// Misses live apart from values so a flood of unknown tenant keys cannot evict the known ones.
|
|
30
|
+
misses;
|
|
31
|
+
inFlight = new Map();
|
|
32
|
+
defaultTtlMs;
|
|
33
|
+
readPolicy;
|
|
34
|
+
selectPolicy;
|
|
35
|
+
notFoundTtlMs;
|
|
36
|
+
missCapPerMinute;
|
|
37
|
+
missWindowStart = Number.NEGATIVE_INFINITY;
|
|
38
|
+
// Distinct select keys the API answered 404 for in the current window, until the cap is reached.
|
|
39
|
+
missedInWindow = new Set();
|
|
40
|
+
// Past the cap a 404 is cached until the window ends: every unseen key still reaches the API once, but no key the API
|
|
41
|
+
// just refused is sent again that minute.
|
|
42
|
+
holdingMisses = false;
|
|
43
|
+
generation = 0;
|
|
44
|
+
now;
|
|
45
|
+
logger;
|
|
46
|
+
constructor(config) {
|
|
47
|
+
// Zero or a negative age would expire every entry on write and turn each read into a resolver call.
|
|
48
|
+
this.defaultTtlMs =
|
|
49
|
+
config.defaultTtlMs ?? readEnvInteger('UNNBOUND_RUNTIME_RESOLVE_CACHE_MAX_AGE', DEFAULT_TTL_MS, 1);
|
|
50
|
+
this.readPolicy = {
|
|
51
|
+
staleIfErrorMs: config.staleIfErrorMs ??
|
|
52
|
+
readEnvInteger('TEMPER_RUNTIME_RESOLVE_STALE_IF_ERROR_MAX_AGE', DEFAULT_STALE_IF_ERROR_MS, 0),
|
|
53
|
+
cacheMisses: false,
|
|
54
|
+
};
|
|
55
|
+
this.selectPolicy = {
|
|
56
|
+
staleIfErrorMs: config.selectStaleIfErrorMs ??
|
|
57
|
+
readEnvInteger('TEMPER_RUNTIME_RESOLVE_SELECT_STALE_IF_ERROR_MAX_AGE', DEFAULT_SELECT_STALE_IF_ERROR_MS, 0),
|
|
58
|
+
cacheMisses: true,
|
|
59
|
+
};
|
|
60
|
+
this.notFoundTtlMs =
|
|
61
|
+
config.notFoundTtlMs ?? readEnvInteger('TEMPER_RUNTIME_RESOLVE_NOT_FOUND_MAX_AGE', DEFAULT_NOT_FOUND_TTL_MS, 0);
|
|
62
|
+
this.missCapPerMinute =
|
|
63
|
+
config.missCapPerMinute ??
|
|
64
|
+
readEnvInteger('TEMPER_RUNTIME_RESOLVE_MISS_CAP_PER_MINUTE', DEFAULT_MISS_CAP_PER_MINUTE, 0);
|
|
65
|
+
const maxEntries = config.maxEntries ?? readEnvInteger('TEMPER_RUNTIME_RESOLVE_CACHE_MAX_ENTRIES', DEFAULT_MAX_ENTRIES, 1);
|
|
66
|
+
this.values = new ExpiringMap(maxEntries);
|
|
67
|
+
this.misses = new ExpiringMap(maxEntries);
|
|
68
|
+
this.now = config.now ?? Date.now;
|
|
69
|
+
this.logger = config.logger;
|
|
70
|
+
}
|
|
71
|
+
async read(target, options, policy, fetch) {
|
|
72
|
+
// A reader can serve multiple workflow identities during its life; a cache hit must belong to this one.
|
|
73
|
+
const key = JSON.stringify([
|
|
74
|
+
process.env.UNNBOUND_API_URL ?? '',
|
|
75
|
+
process.env.UNNBOUND_WORKFLOW_ID ?? '',
|
|
76
|
+
process.env.UNNBOUND_DEPLOYMENT_ID ?? '',
|
|
77
|
+
process.env.TEMPER_ENVIRONMENT ?? process.env.UNNBOUND_ENVIRONMENT ?? '',
|
|
78
|
+
target,
|
|
79
|
+
]);
|
|
80
|
+
// SAFETY: `key` encodes the operation, so every value under it was stored by the same call site with the same `A`.
|
|
81
|
+
const deliver = (value) => structuredClone(value);
|
|
82
|
+
if (options?.cache === false) {
|
|
83
|
+
const started = this.nextGeneration();
|
|
84
|
+
try {
|
|
85
|
+
const value = await fetch();
|
|
86
|
+
this.invalidate(key, started);
|
|
87
|
+
return deliver(value);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Only an outage leaves the cache alone; any API answer replaces what the cache knew about this key.
|
|
91
|
+
if (!(error instanceof Error && isOutage(error)))
|
|
92
|
+
this.invalidate(key, started);
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const now = this.now();
|
|
97
|
+
const entry = this.values.get(key, now);
|
|
98
|
+
if (entry && (now < entry.freshUntil || now < entry.retryAt))
|
|
99
|
+
return deliver(entry.value);
|
|
100
|
+
const miss = this.misses.get(key, now);
|
|
101
|
+
if (miss)
|
|
102
|
+
throw new ResourceNotFoundError({ target: miss.error.target, message: miss.error.message });
|
|
103
|
+
const existing = this.inFlight.get(key);
|
|
104
|
+
if (existing)
|
|
105
|
+
return deliver(await existing.promise);
|
|
106
|
+
const token = { superseded: false, generation: this.nextGeneration() };
|
|
107
|
+
const load = {
|
|
108
|
+
token,
|
|
109
|
+
promise: this.load(key, fetch, options?.ttlMs ?? this.defaultTtlMs, policy, token),
|
|
110
|
+
};
|
|
111
|
+
this.inFlight.set(key, load);
|
|
112
|
+
try {
|
|
113
|
+
return deliver(await load.promise);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
if (this.inFlight.get(key) === load)
|
|
117
|
+
this.inFlight.delete(key);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
nextGeneration() {
|
|
121
|
+
this.generation += 1;
|
|
122
|
+
return this.generation;
|
|
123
|
+
}
|
|
124
|
+
rollMissWindow(now) {
|
|
125
|
+
if (now - this.missWindowStart < MISS_WINDOW_MS)
|
|
126
|
+
return;
|
|
127
|
+
this.missWindowStart = now;
|
|
128
|
+
this.missedInWindow.clear();
|
|
129
|
+
this.holdingMisses = false;
|
|
130
|
+
}
|
|
131
|
+
// The cap limits the rate of distinct confirmed misses, never a first request: a valid tenant this process has not
|
|
132
|
+
// seen is indistinguishable from a rotating miss until the API answers. Returns when the 404 stops being cached.
|
|
133
|
+
recordConfirmedMiss(key, now) {
|
|
134
|
+
const expiresAt = now + this.notFoundTtlMs;
|
|
135
|
+
if (this.missCapPerMinute === 0)
|
|
136
|
+
return expiresAt;
|
|
137
|
+
this.rollMissWindow(now);
|
|
138
|
+
const windowEnd = this.missWindowStart + MISS_WINDOW_MS;
|
|
139
|
+
if (!this.holdingMisses) {
|
|
140
|
+
this.missedInWindow.add(key);
|
|
141
|
+
if (this.missedInWindow.size < this.missCapPerMinute)
|
|
142
|
+
return expiresAt;
|
|
143
|
+
this.holdingMisses = true;
|
|
144
|
+
// The 404s that filled the cap are held too, unless a newer answer or eviction already removed them.
|
|
145
|
+
for (const missed of this.missedInWindow)
|
|
146
|
+
this.misses.extend(missed, windowEnd, now);
|
|
147
|
+
this.missedInWindow.clear();
|
|
148
|
+
this.logger.warn({ missCapPerMinute: this.missCapPerMinute }, 'Runtime resolver select miss cap reached; keys answered 404 are not sent again until the minute ends.');
|
|
149
|
+
}
|
|
150
|
+
return Math.max(expiresAt, windowEnd);
|
|
151
|
+
}
|
|
152
|
+
// A `cache: false` answer replaces what older reads cached or still have in flight; a read that started after the
|
|
153
|
+
// bypass carries a newer answer and stays.
|
|
154
|
+
invalidate(key, started) {
|
|
155
|
+
const value = this.values.peek(key);
|
|
156
|
+
if (value && value.generation < started)
|
|
157
|
+
this.values.delete(key);
|
|
158
|
+
const miss = this.misses.peek(key);
|
|
159
|
+
if (miss && miss.generation < started)
|
|
160
|
+
this.misses.delete(key);
|
|
161
|
+
const pending = this.inFlight.get(key);
|
|
162
|
+
if (pending && pending.token.generation < started) {
|
|
163
|
+
pending.token.superseded = true;
|
|
164
|
+
this.inFlight.delete(key);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// An outage serves the last good value; any answer from the resolver (401, 403, 404, 409) drops it.
|
|
168
|
+
async load(key, fetch, ttlMs, policy, token) {
|
|
169
|
+
try {
|
|
170
|
+
const value = await fetch();
|
|
171
|
+
// A refresh that a newer `cache: false` answer superseded must not write its older answer back.
|
|
172
|
+
if (token.superseded)
|
|
173
|
+
return value;
|
|
174
|
+
const now = this.now();
|
|
175
|
+
const freshUntil = now + ttlMs;
|
|
176
|
+
const entry = { value, freshUntil, retryAt: 0, warned: false, generation: token.generation };
|
|
177
|
+
this.values.set(key, entry, freshUntil + policy.staleIfErrorMs, now, freshUntil);
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
// A superseded answer is older than the bypass that replaced it: it neither counts as a miss nor changes the cache.
|
|
182
|
+
if (token.superseded)
|
|
183
|
+
throw error;
|
|
184
|
+
const now = this.now();
|
|
185
|
+
if (!(error instanceof Error && isOutage(error))) {
|
|
186
|
+
this.values.delete(key);
|
|
187
|
+
if (policy.cacheMisses && error instanceof ResourceNotFoundError) {
|
|
188
|
+
const expiresAt = this.recordConfirmedMiss(key, now);
|
|
189
|
+
this.misses.set(key, { error, generation: token.generation }, expiresAt, now);
|
|
190
|
+
}
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
const last = this.values.get(key, now);
|
|
194
|
+
if (!last)
|
|
195
|
+
throw error;
|
|
196
|
+
last.retryAt = now + RETRY_AFTER_UNAVAILABLE_MS;
|
|
197
|
+
if (!last.warned) {
|
|
198
|
+
last.warned = true;
|
|
199
|
+
this.logger.warn({ err: error.message, staleForMs: now - last.freshUntil }, 'Runtime resolver unavailable; serving the last good value.');
|
|
200
|
+
}
|
|
201
|
+
return last.value;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=ResourcesCache.js.map
|