@configdirector/server-sdk 1.10.0 → 1.11.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/dist/DefaultConfigDirectorClient-BoqR23zq.cjs +5 -0
- package/dist/DefaultConfigDirectorClient-z8HbdUmy.mjs +6 -0
- package/dist/DefaultConfigDirectorClient-z8HbdUmy.mjs.map +1 -0
- package/dist/configdirector-server-testing.cjs +1 -1
- package/dist/configdirector-server-testing.d.cts +5 -25
- package/dist/configdirector-server-testing.d.cts.map +1 -1
- package/dist/configdirector-server-testing.d.mts +5 -25
- package/dist/configdirector-server-testing.d.mts.map +1 -1
- package/dist/configdirector-server-testing.mjs +1 -1
- package/dist/configdirector-server-testing.mjs.map +1 -1
- package/dist/configdirector-server.cjs +1 -1
- package/dist/configdirector-server.d.cts +26 -3
- package/dist/configdirector-server.d.cts.map +1 -1
- package/dist/configdirector-server.d.mts +26 -3
- package/dist/configdirector-server.d.mts.map +1 -1
- package/dist/configdirector-server.mjs +1 -1
- package/dist/configdirector-server.mjs.map +1 -1
- package/dist/{types-KjDfmG_p.d.cts → errors-BCEfxVqM.d.mts} +108 -38
- package/dist/errors-BCEfxVqM.d.mts.map +1 -0
- package/dist/{types-BvNBpCHC.d.mts → errors-C7n65Oc5.d.cts} +108 -38
- package/dist/errors-C7n65Oc5.d.cts.map +1 -0
- package/package.json +1 -1
- package/dist/DefaultConfigDirectorClient-CJqto-ZO.mjs +0 -6
- package/dist/DefaultConfigDirectorClient-CJqto-ZO.mjs.map +0 -1
- package/dist/DefaultConfigDirectorClient-Cr8DoZII.cjs +0 -5
- package/dist/types-BvNBpCHC.d.mts.map +0 -1
- package/dist/types-KjDfmG_p.d.cts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as e,i as t,n,r,s as i,t as a}from"./DefaultConfigDirectorClient-z8HbdUmy.mjs";import o from"node:events";const s={environmentId:`test-environment`,projectId:`test-project`};var c=class{constructor(e,t){this.logger=e,this.emitter=new o,this.configs=new Map,this.pendingDeliveries=[],this.armed=`nothing`,this.connected=!1,this.delivering=!1,this.encodeAll(t).forEach((e,t)=>this.configs.set(t,e))}setValue(e,t){let n=this.encode(e,t);this.configs.set(e,n),this.deliverIfConnected({...s,kind:`delta`,configs:{[e]:n}})}removeValue(e){this.configs.delete(e),this.deliverIfConnected(this.fullUpdate())}replaceValues(e){let t=this.encodeAll(e);this.configs.clear(),t.forEach((e,t)=>this.configs.set(t,e)),this.armed=`nothing`,this.deliverIfConnected(this.fullUpdate())}hold(){this.armed=`hold`}complete(){this.pendingHold?this.pendingHold.complete():this.armed===`hold`&&(this.armed=`nothing`)}fail(){this.pendingHold?this.pendingHold.fail():this.armed=`failure`}connect(e){this.endAttempt();let t=this.armed;switch(this.armed=`nothing`,t){case`failure`:return this.failNow();case`hold`:return this.holdNow(e);default:return this.connectNow(),Promise.resolve(this)}}get isConnected(){return this.connected}on(e,t){this.emitter.on(e,t)}off(e,t){t?this.emitter.off(e,t):this.emitter.removeAllListeners(e)}close(){this.endAttempt()}dispose(){this.close(),this.emitter.removeAllListeners()}endAttempt(){this.connected=!1,this.pendingHold?.end()}connectNow(){this.connected=!0,this.deliver(this.fullUpdate())}holdNow(e){return new Promise((t,n)=>{let r=setTimeout(()=>this.pendingHold?.end(),e),i=()=>{clearTimeout(r),this.pendingHold=void 0};this.pendingHold={end:()=>{i(),t(this)},complete:()=>{i(),this.connectNow(),t(this)},fail:()=>{i();let e=this.fatalError();this.emitter.emit(`connectionError`,e),n(e)}}})}failNow(){let e=this.fatalError();return this.emitter.emit(`connectionError`,e),Promise.reject(e)}fatalError(){return new e(`Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.`,401)}deliverIfConnected(e){this.connected&&this.deliver(e)}deliver(e){if(this.pendingDeliveries.push(e),!this.delivering){this.delivering=!0;try{let e=this.pendingDeliveries.shift();for(;e;)this.emitCaught(e),e=this.pendingDeliveries.shift()}finally{this.delivering=!1}}}emitCaught(e){try{this.emitter.emit(`configBundleReceived`,e)}catch(e){this.logger.error(`[InMemoryConnection] Error dispatching a config update from the test client: `,e)}}fullUpdate(){return{...s,kind:`full`,configs:Object.fromEntries(this.configs)}}encodeAll(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n,this.encode(n,r));return t}encode(e,n){return t(`test-config:${e}`,e,n)}},l=class{constructor(e,t){this.client=e,this.connection=t}setValue(e,t){this.connection.setValue(e,t)}removeValue(e){this.connection.removeValue(e)}replaceValues(e){this.connection.replaceValues(e)}holdInitialization(){this.connection.hold()}completeInitialization(){this.connection.complete()}failInitialization(){this.connection.fail()}};const u=(e,t)=>{let i=t?.logger??r(),o=new c(i,t?.values??{});return new l(new a(`test-client`,e,{logger:i,connection:{timeout:t?.timeout}},{transport:o,telemetry:n}),o)},d=e=>u({sdkName:`js-server-sdk`,sdkVersion:`1.11.0`},e);export{e as ConfigDirectorConnectionError,i as ConfigDirectorValidationError,d as createTestClient};
|
|
2
2
|
//# sourceMappingURL=configdirector-server-testing.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-server-testing.mjs","names":["encodeTestValue","encodeShared","createTestClient"],"sources":["../../shared/src/testing/values.ts","../src/testing/values.ts","../src/testing/InMemoryConnection.ts","../src/testing/TestClient.ts","../src/testing.ts"],"sourcesContent":["import type { ConfigType } from \"../types\";\nimport { ConfigDirectorValidationError } from \"../errors\";\n\nexport type TestJsonValue = boolean | number | string | null | TestJsonValue[] | { [key: string]: TestJsonValue };\n\nexport type TestValue = boolean | number | string | TestJsonValue[] | { [key: string]: TestJsonValue };\n\nexport type TestValues = Record<string, TestValue>;\n\nexport type EncodedTestValue = { type: ConfigType; value: string };\n\nexport const encodeTestValue = (key: string, value: TestValue): EncodedTestValue => {\n if (key.trim().length == 0) {\n throw new ConfigDirectorValidationError(\"Invalid config key. The key of a test value cannot be empty.\");\n }\n return encode(key, value);\n};\n\nconst encode = (key: string, value: TestValue): EncodedTestValue => {\n switch (typeof value) {\n case \"boolean\":\n return { type: \"boolean\", value: value ? \"true\" : \"false\" };\n case \"number\":\n return encodeNumber(key, value);\n case \"string\":\n return { type: \"string\", value };\n case \"object\":\n if (value !== null) {\n assertJsonContents(key, value, \"\");\n return { type: \"json\", value: JSON.stringify(value) };\n }\n }\n throw new ConfigDirectorValidationError(\n `Invalid test value for '${key}': ${describe(value)}. Use a boolean, a number, a string, a plain object, or an array.`,\n );\n};\n\nconst encodeNumber = (key: string, value: number): EncodedTestValue => {\n if (!Number.isFinite(value)) {\n throw new ConfigDirectorValidationError(`Invalid test value for '${key}': ${describe(value)} is not a finite number.`);\n }\n if (Number.isInteger(value)) {\n if (!Number.isSafeInteger(value)) {\n throw new ConfigDirectorValidationError(\n `Invalid test value for '${key}': ${value} is not a safe integer, so the SDK could not read it back exactly.`,\n );\n }\n return { type: \"integer\", value: String(value) };\n }\n return { type: \"float\", value: toPlainDecimal(value) };\n};\n\nconst toPlainDecimal = (value: number): string => {\n const text = String(value);\n const exponentIndex = text.indexOf(\"e-\");\n if (exponentIndex < 0) {\n return text;\n }\n const sign = text.startsWith(\"-\") ? \"-\" : \"\";\n const [integerDigits = \"\", fractionDigits = \"\"] = text.slice(sign.length, exponentIndex).split(\".\");\n const leadingZeros = Number(text.slice(exponentIndex + 2)) - integerDigits.length;\n return `${sign}0.${\"0\".repeat(leadingZeros)}${integerDigits}${fractionDigits}`;\n};\n\nconst assertJsonContents = (key: string, value: unknown, path: string): void => {\n if (value === null || typeof value === \"boolean\" || typeof value === \"string\") {\n return;\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) {\n throw invalidJsonContents(key, path, `${describe(value)} is not a finite number`);\n }\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => assertJsonContents(key, item, `${path}[${index}]`));\n return;\n }\n if (isPlainObject(value)) {\n for (const [property, item] of Object.entries(value)) {\n assertJsonContents(key, item, path ? `${path}.${property}` : property);\n }\n return;\n }\n throw invalidJsonContents(key, path, `${describe(value)} cannot be encoded as JSON`);\n};\n\nconst invalidJsonContents = (key: string, path: string, problem: string) =>\n new ConfigDirectorValidationError(\n `Invalid test value for '${key}'${path ? ` at '${path}'` : \"\"}: ${problem}. JSON contents can hold booleans, finite numbers, strings, null, arrays, and plain objects.`,\n );\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\nconst describe = (value: unknown): string => {\n if (value === null) {\n return \"null\";\n }\n if (typeof value === \"function\") {\n return \"a function\";\n }\n if (typeof value === \"object\") {\n return `a ${value.constructor?.name ?? \"object\"} instance`;\n }\n if (typeof value === \"symbol\") {\n return \"a symbol\";\n }\n return String(value);\n};\n","import type { ConfigDefinition } from \"../types\";\nimport { encodeTestValue as encodeShared } from \"@shared/testing/values\";\nimport type { TestValue } from \"@shared/testing/values\";\n\nexport type { TestJsonValue, TestValue, TestValues } from \"@shared/testing/values\";\n\nexport const encodeTestValue = (key: string, value: TestValue): ConfigDefinition => {\n const encoded = encodeShared(key, value);\n return {\n id: `test-config:${key}`,\n key,\n type: encoded.type,\n variations: [{ name: null, value: encoded.value }],\n target: { defaultValue: encoded.value, rules: [] },\n };\n};\n","import EventEmitter from \"node:events\";\nimport type { ConfigBundle, ConfigDefinition, ConfigDirectorLogger, Transport, TransportEvents } from \"../types\";\nimport { ConfigDirectorConnectionError } from \"@shared/errors\";\nimport { encodeTestValue, type TestValue, type TestValues } from \"./values\";\n\ntype Armed = \"nothing\" | \"hold\" | \"failure\";\n\ntype PendingHold = {\n end: () => void;\n complete: () => void;\n fail: () => void;\n};\n\nconst TEST_ENVIRONMENT = { environmentId: \"test-environment\", projectId: \"test-project\" };\n\nexport class InMemoryConnection implements Transport {\n private readonly emitter = new EventEmitter();\n private readonly configs = new Map<string, ConfigDefinition>();\n private readonly pendingDeliveries: ConfigBundle[] = [];\n private armed: Armed = \"nothing\";\n private pendingHold: PendingHold | undefined;\n private connected = false;\n private delivering = false;\n\n constructor(\n private readonly logger: ConfigDirectorLogger,\n values: TestValues,\n ) {\n this.encodeAll(values).forEach((definition, key) => this.configs.set(key, definition));\n }\n\n public setValue(key: string, value: TestValue) {\n const definition = encodeTestValue(key, value);\n this.configs.set(key, definition);\n this.deliverIfConnected({ ...TEST_ENVIRONMENT, kind: \"delta\", configs: { [key]: definition } });\n }\n\n public removeValue(key: string) {\n this.configs.delete(key);\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public replaceValues(values: TestValues) {\n const encoded = this.encodeAll(values);\n this.configs.clear();\n encoded.forEach((definition, key) => this.configs.set(key, definition));\n this.armed = \"nothing\";\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public hold() {\n this.armed = \"hold\";\n }\n\n public complete() {\n if (this.pendingHold) {\n this.pendingHold.complete();\n } else if (this.armed === \"hold\") {\n this.armed = \"nothing\";\n }\n }\n\n public fail() {\n if (this.pendingHold) {\n this.pendingHold.fail();\n } else {\n this.armed = \"failure\";\n }\n }\n\n public connect(timeout: number): Promise<this> {\n this.endAttempt();\n const armed = this.armed;\n this.armed = \"nothing\";\n switch (armed) {\n case \"failure\":\n return this.failNow();\n case \"hold\":\n return this.holdNow(timeout);\n default:\n this.connectNow();\n return Promise.resolve(this);\n }\n }\n\n public get isConnected(): boolean {\n return this.connected;\n }\n\n public on<TName extends keyof TransportEvents>(name: TName, handler: (payload: TransportEvents[TName]) => void) {\n this.emitter.on(name, handler);\n }\n\n public off<TName extends keyof TransportEvents>(name: TName, handler?: (payload: TransportEvents[TName]) => void) {\n if (handler) {\n this.emitter.off(name, handler);\n } else {\n this.emitter.removeAllListeners(name);\n }\n }\n\n public close() {\n this.endAttempt();\n }\n\n public dispose() {\n this.close();\n this.emitter.removeAllListeners();\n }\n\n private endAttempt() {\n this.connected = false;\n this.pendingHold?.end();\n }\n\n private connectNow() {\n this.connected = true;\n this.deliver(this.fullUpdate());\n }\n\n private holdNow(timeout: number): Promise<this> {\n return new Promise<this>((resolve, reject) => {\n const timer = setTimeout(() => this.pendingHold?.end(), timeout);\n const release = () => {\n clearTimeout(timer);\n this.pendingHold = undefined;\n };\n this.pendingHold = {\n end: () => {\n release();\n resolve(this);\n },\n complete: () => {\n release();\n this.connectNow();\n resolve(this);\n },\n fail: () => {\n release();\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n reject(error);\n },\n };\n });\n }\n\n private failNow(): Promise<this> {\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n return Promise.reject(error);\n }\n\n private fatalError() {\n return new ConfigDirectorConnectionError(\n \"Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.\",\n 401,\n );\n }\n\n private deliverIfConnected(configBundle: ConfigBundle) {\n if (this.connected) {\n this.deliver(configBundle);\n }\n }\n\n private deliver(configBundle: ConfigBundle) {\n this.pendingDeliveries.push(configBundle);\n if (this.delivering) {\n return;\n }\n this.delivering = true;\n try {\n let next = this.pendingDeliveries.shift();\n while (next) {\n this.emitCaught(next);\n next = this.pendingDeliveries.shift();\n }\n } finally {\n this.delivering = false;\n }\n }\n\n private emitCaught(configBundle: ConfigBundle) {\n try {\n this.emitter.emit(\"configBundleReceived\", configBundle);\n } catch (error) {\n this.logger.error(\"[InMemoryConnection] Error dispatching a config update from the test client: \", error);\n }\n }\n\n private fullUpdate(): ConfigBundle {\n return { ...TEST_ENVIRONMENT, kind: \"full\", configs: Object.fromEntries(this.configs) };\n }\n\n private encodeAll(values: TestValues): Map<string, ConfigDefinition> {\n const encoded = new Map<string, ConfigDefinition>();\n for (const [key, value] of Object.entries(values)) {\n encoded.set(key, encodeTestValue(key, value));\n }\n return encoded;\n }\n}\n","import { DefaultConfigDirectorClient } from \"../DefaultConfigDirectorClient\";\nimport { createDefaultLogger } from \"../logger\";\nimport type { ConfigDirectorClient, ConfigDirectorLogger, IdentifyingSdkOptions } from \"../types\";\nimport type { ServerTelemetryClient } from \"../telemetry\";\nimport { InMemoryConnection } from \"./InMemoryConnection\";\nimport type { TestValue, TestValues } from \"./values\";\n\nconst TEST_CLIENT_SDK_KEY = \"test-client\";\n\n/**\n * Options for {@link createTestClient}. Every option is optional.\n */\nexport type TestClientOptions = {\n /**\n * The config values the test client serves once its client connects, keyed by config key. The\n * config type follows from each value: a boolean, an integral number (`integer`), any other\n * number (`float`), a string, or a plain object or array (`json`). Every context receives the\n * same value.\n */\n values?: TestValues;\n /**\n * The connection timeout of the SDK client, in milliseconds. It bounds how long a held\n * `initialize` waits. Defaults to the SDK's production timeout.\n */\n timeout?: number;\n /**\n * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since\n * the test client sends no telemetry, every read that supplies a context with an invalid kind\n * logs an error, rather than each invalid kind once per telemetry interval.\n */\n logger?: ConfigDirectorLogger;\n};\n\n/**\n * A real ConfigDirector client connected to an in-memory server that the test controls.\n *\n * The client under {@link TestClient.client} is the SDK's production client: value parsing,\n * targeting evaluation, watchers, events, and readiness behave as they do against ConfigDirector.\n * Only the network connection and telemetry are replaced, so no request is ever made and nothing\n * is left running after the client is disposed.\n */\nexport interface TestClient {\n /**\n * The SDK client to hand to the code under test. It starts uninitialized, like a production\n * client; `initialize` completes at once with the seeded values unless initialization is held.\n */\n readonly client: ConfigDirectorClient;\n\n /**\n * Stores `value` under `key` and, when the client is connected, delivers it as an update, so\n * reads, watchers, and `configsUpdated` handlers see it.\n */\n setValue(key: string, value: TestValue): void;\n\n /**\n * Removes `key` and, when the client is connected, delivers a full update without it, so reads\n * fall back to the in-code default value and watchers of `key` receive that default.\n */\n removeValue(key: string): void;\n\n /**\n * Replaces every stored value with `values`, disarms any armed hold or failure, and, when the\n * client is connected, delivers the new values as a full update.\n */\n replaceValues(values: TestValues): void;\n\n /**\n * Makes the next `initialize` wait until {@link completeInitialization} or\n * {@link failInitialization} is called, or until the client's timeout elapses.\n */\n holdInitialization(): void;\n\n /**\n * Delivers the stored values to a held `initialize`, so it completes with the client ready. When\n * a hold is armed but no `initialize` has started, it disarms the hold instead.\n */\n completeInitialization(): void;\n\n /**\n * Fails a held `initialize` with an unrecoverable connection error, or arms the next `initialize`\n * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.\n */\n failInitialization(): void;\n}\n\nconst noopTelemetryClient: ServerTelemetryClient = {\n start: () => {},\n evaluatedConfig: () => {},\n recordInvalidContext: () => \"new-kind-sample\",\n close: async () => {},\n};\n\nclass InMemoryTestClient implements TestClient {\n constructor(\n public readonly client: ConfigDirectorClient,\n private readonly connection: InMemoryConnection,\n ) {}\n\n public setValue(key: string, value: TestValue) {\n this.connection.setValue(key, value);\n }\n\n public removeValue(key: string) {\n this.connection.removeValue(key);\n }\n\n public replaceValues(values: TestValues) {\n this.connection.replaceValues(values);\n }\n\n public holdInitialization() {\n this.connection.hold();\n }\n\n public completeInitialization() {\n this.connection.complete();\n }\n\n public failInitialization() {\n this.connection.fail();\n }\n}\n\nexport const createTestClient = (sdkOptions: IdentifyingSdkOptions, options?: TestClientOptions): TestClient => {\n const logger = options?.logger ?? createDefaultLogger();\n const connection = new InMemoryConnection(logger, options?.values ?? {});\n const client = new DefaultConfigDirectorClient(\n TEST_CLIENT_SDK_KEY,\n sdkOptions,\n { logger, connection: { timeout: options?.timeout } },\n { transport: connection, telemetry: noopTelemetryClient },\n );\n return new InMemoryTestClient(client, connection);\n};\n","import { createTestClient as createInMemoryTestClient } from \"./testing/TestClient\";\nimport type { TestClient, TestClientOptions } from \"./testing/TestClient\";\n\nexport type { TestClient, TestClientOptions } from \"./testing/TestClient\";\nexport type { TestValue, TestValues, TestJsonValue } from \"./testing/values\";\nexport { ConfigDirectorConnectionError, ConfigDirectorValidationError } from \"@shared/errors\";\n\n/**\n * Creates a {@link TestClient}: a real `ConfigDirectorClient` connected to an in-memory server\n * that the test controls. No network connection is opened and no telemetry is sent.\n *\n * @param options {@link TestClientOptions}: the initial values, the client's timeout, and its logger\n * @returns A {@link TestClient} whose `client` is passed to the code under test\n *\n * @example\n * import { createTestClient } from \"@configdirector/server-sdk/testing\";\n *\n * const testClient = createTestClient({ values: { \"new-checkout\": true } });\n * await testClient.client.initialize();\n * expect(testClient.client.getValue(\"new-checkout\", false)).toBe(true);\n *\n * testClient.setValue(\"new-checkout\", false);\n */\nexport const createTestClient = (options?: TestClientOptions): TestClient => {\n return createInMemoryTestClient({ sdkName: \"js-server-sdk\", sdkVersion: \"__VERSION__\" }, options);\n};\n"],"mappings":"+GAWA,MAAaA,GAAmB,EAAa,IAAuC,CAClF,GAAI,EAAI,MAAM,CAAC,QAAU,EACvB,MAAM,IAAI,EAA8B,+DAA+D,CAEzG,OAAO,EAAO,EAAK,EAAM,EAGrB,GAAU,EAAa,IAAuC,CAClE,OAAQ,OAAO,EAAf,CACE,IAAK,UACH,MAAO,CAAE,KAAM,UAAW,MAAO,EAAQ,OAAS,QAAS,CAC7D,IAAK,SACH,OAAO,EAAa,EAAK,EAAM,CACjC,IAAK,SACH,MAAO,CAAE,KAAM,SAAU,QAAO,CAClC,IAAK,SACH,GAAI,IAAU,KAEZ,OADA,EAAmB,EAAK,EAAO,GAAG,CAC3B,CAAE,KAAM,OAAQ,MAAO,KAAK,UAAU,EAAM,CAAE,CAG3D,MAAM,IAAI,EACR,2BAA2B,EAAI,KAAK,EAAS,EAAM,CAAC,mEACrD,EAGG,GAAgB,EAAa,IAAoC,CACrE,GAAI,CAAC,OAAO,SAAS,EAAM,CACzB,MAAM,IAAI,EAA8B,2BAA2B,EAAI,KAAK,EAAS,EAAM,CAAC,0BAA0B,CAExH,GAAI,OAAO,UAAU,EAAM,CAAE,CAC3B,GAAI,CAAC,OAAO,cAAc,EAAM,CAC9B,MAAM,IAAI,EACR,2BAA2B,EAAI,KAAK,EAAM,oEAC3C,CAEH,MAAO,CAAE,KAAM,UAAW,MAAO,OAAO,EAAM,CAAE,CAElD,MAAO,CAAE,KAAM,QAAS,MAAO,EAAe,EAAM,CAAE,EAGlD,EAAk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AAU,CAG5B,oBAA4B,CAC1B,KAAK,WAAW,MAAM,GAI1B,MAAaC,GAAoB,EAAmC,IAA4C,CAC9G,IAAM,EAAS,GAAS,QAAU,GAAqB,CACjD,EAAa,IAAI,EAAmB,EAAQ,GAAS,QAAU,EAAE,CAAC,CAOxE,OAAO,IAAI,EANI,IAAI,EACjB,cACA,EACA,CAAE,SAAQ,WAAY,CAAE,QAAS,GAAS,QAAS,CAAE,CACrD,CAAE,UAAW,EAAY,UAAW,EAAqB,CAC1D,CACqC,EAAW,EC7GtC,EAAoB,GACxB,EAAyB,CAAE,QAAS,gBAAiB,WAAY,SAAe,CAAE,EAAQ"}
|
|
1
|
+
{"version":3,"file":"configdirector-server-testing.mjs","names":["createTestClient"],"sources":["../src/testing/InMemoryConnection.ts","../src/testing/TestClient.ts","../src/testing.ts"],"sourcesContent":["import EventEmitter from \"node:events\";\nimport type { ConfigBundle, ConfigDefinition, ConfigDirectorLogger, Transport, TransportEvents } from \"../types\";\nimport { ConfigDirectorConnectionError } from \"@shared/errors\";\nimport type { TestValue, TestValues } from \"./values\";\nimport { unconditionalConfig } from \"../native-values\";\n\ntype Armed = \"nothing\" | \"hold\" | \"failure\";\n\ntype PendingHold = {\n end: () => void;\n complete: () => void;\n fail: () => void;\n};\n\nconst TEST_ENVIRONMENT = { environmentId: \"test-environment\", projectId: \"test-project\" };\n\nexport class InMemoryConnection implements Transport {\n private readonly emitter = new EventEmitter();\n private readonly configs = new Map<string, ConfigDefinition>();\n private readonly pendingDeliveries: ConfigBundle[] = [];\n private armed: Armed = \"nothing\";\n private pendingHold: PendingHold | undefined;\n private connected = false;\n private delivering = false;\n\n constructor(\n private readonly logger: ConfigDirectorLogger,\n values: TestValues,\n ) {\n this.encodeAll(values).forEach((definition, key) => this.configs.set(key, definition));\n }\n\n public setValue(key: string, value: TestValue) {\n const definition = this.encode(key, value);\n this.configs.set(key, definition);\n this.deliverIfConnected({ ...TEST_ENVIRONMENT, kind: \"delta\", configs: { [key]: definition } });\n }\n\n public removeValue(key: string) {\n this.configs.delete(key);\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public replaceValues(values: TestValues) {\n const encoded = this.encodeAll(values);\n this.configs.clear();\n encoded.forEach((definition, key) => this.configs.set(key, definition));\n this.armed = \"nothing\";\n this.deliverIfConnected(this.fullUpdate());\n }\n\n public hold() {\n this.armed = \"hold\";\n }\n\n public complete() {\n if (this.pendingHold) {\n this.pendingHold.complete();\n } else if (this.armed === \"hold\") {\n this.armed = \"nothing\";\n }\n }\n\n public fail() {\n if (this.pendingHold) {\n this.pendingHold.fail();\n } else {\n this.armed = \"failure\";\n }\n }\n\n public connect(timeout: number): Promise<this> {\n this.endAttempt();\n const armed = this.armed;\n this.armed = \"nothing\";\n switch (armed) {\n case \"failure\":\n return this.failNow();\n case \"hold\":\n return this.holdNow(timeout);\n default:\n this.connectNow();\n return Promise.resolve(this);\n }\n }\n\n public get isConnected(): boolean {\n return this.connected;\n }\n\n public on<TName extends keyof TransportEvents>(name: TName, handler: (payload: TransportEvents[TName]) => void) {\n this.emitter.on(name, handler);\n }\n\n public off<TName extends keyof TransportEvents>(name: TName, handler?: (payload: TransportEvents[TName]) => void) {\n if (handler) {\n this.emitter.off(name, handler);\n } else {\n this.emitter.removeAllListeners(name);\n }\n }\n\n public close() {\n this.endAttempt();\n }\n\n public dispose() {\n this.close();\n this.emitter.removeAllListeners();\n }\n\n private endAttempt() {\n this.connected = false;\n this.pendingHold?.end();\n }\n\n private connectNow() {\n this.connected = true;\n this.deliver(this.fullUpdate());\n }\n\n private holdNow(timeout: number): Promise<this> {\n return new Promise<this>((resolve, reject) => {\n const timer = setTimeout(() => this.pendingHold?.end(), timeout);\n const release = () => {\n clearTimeout(timer);\n this.pendingHold = undefined;\n };\n this.pendingHold = {\n end: () => {\n release();\n resolve(this);\n },\n complete: () => {\n release();\n this.connectNow();\n resolve(this);\n },\n fail: () => {\n release();\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n reject(error);\n },\n };\n });\n }\n\n private failNow(): Promise<this> {\n const error = this.fatalError();\n this.emitter.emit(\"connectionError\", error);\n return Promise.reject(error);\n }\n\n private fatalError() {\n return new ConfigDirectorConnectionError(\n \"Connection failed with status: 401. Error: the test client failed this initialization. This is an unrecoverable error, will not attempt to reconnect.\",\n 401,\n );\n }\n\n private deliverIfConnected(configBundle: ConfigBundle) {\n if (this.connected) {\n this.deliver(configBundle);\n }\n }\n\n private deliver(configBundle: ConfigBundle) {\n this.pendingDeliveries.push(configBundle);\n if (this.delivering) {\n return;\n }\n this.delivering = true;\n try {\n let next = this.pendingDeliveries.shift();\n while (next) {\n this.emitCaught(next);\n next = this.pendingDeliveries.shift();\n }\n } finally {\n this.delivering = false;\n }\n }\n\n private emitCaught(configBundle: ConfigBundle) {\n try {\n this.emitter.emit(\"configBundleReceived\", configBundle);\n } catch (error) {\n this.logger.error(\"[InMemoryConnection] Error dispatching a config update from the test client: \", error);\n }\n }\n\n private fullUpdate(): ConfigBundle {\n return { ...TEST_ENVIRONMENT, kind: \"full\", configs: Object.fromEntries(this.configs) };\n }\n\n private encodeAll(values: TestValues): Map<string, ConfigDefinition> {\n const encoded = new Map<string, ConfigDefinition>();\n for (const [key, value] of Object.entries(values)) {\n encoded.set(key, this.encode(key, value));\n }\n return encoded;\n }\n\n private encode(key: string, value: TestValue): ConfigDefinition {\n return unconditionalConfig(`test-config:${key}`, key, value);\n }\n}\n","import { DefaultConfigDirectorClient } from \"../DefaultConfigDirectorClient\";\nimport { createDefaultLogger } from \"../logger\";\nimport type { ConfigDirectorClient, ConfigDirectorLogger, IdentifyingSdkOptions } from \"../types\";\nimport { discardingTelemetryClient } from \"../telemetry/discarding\";\nimport { InMemoryConnection } from \"./InMemoryConnection\";\nimport type { TestValue, TestValues } from \"./values\";\n\nconst TEST_CLIENT_SDK_KEY = \"test-client\";\n\n/**\n * Options for {@link createTestClient}. Every option is optional.\n */\nexport type TestClientOptions = {\n /**\n * The config values the test client serves once its client connects, keyed by config key. The\n * config type follows from each value: a boolean, an integral number (`integer`), any other\n * number (`float`), a string, or a plain object or array (`json`). Every context receives the\n * same value.\n */\n values?: TestValues;\n /**\n * The connection timeout of the SDK client, in milliseconds. It bounds how long a held\n * `initialize` waits. Defaults to the SDK's production timeout.\n */\n timeout?: number;\n /**\n * The logger the SDK client uses. Defaults to the SDK's console logger at `warn` level. Since\n * the test client sends no telemetry, every read that supplies a context with an invalid kind\n * logs an error, rather than each invalid kind once per telemetry interval.\n */\n logger?: ConfigDirectorLogger;\n};\n\n/**\n * A real ConfigDirector client connected to an in-memory server that the test controls.\n *\n * The client under {@link TestClient.client} is the SDK's production client: value parsing,\n * targeting evaluation, watchers, events, and readiness behave as they do against ConfigDirector.\n * Only the network connection and telemetry are replaced, so no request is ever made and nothing\n * is left running after the client is disposed.\n */\nexport interface TestClient {\n /**\n * The SDK client to hand to the code under test. It starts uninitialized, like a production\n * client; `initialize` completes at once with the seeded values unless initialization is held.\n */\n readonly client: ConfigDirectorClient;\n\n /**\n * Stores `value` under `key` and, when the client is connected, delivers it as an update, so\n * reads, watchers, and `configsUpdated` handlers see it.\n */\n setValue(key: string, value: TestValue): void;\n\n /**\n * Removes `key` and, when the client is connected, delivers a full update without it, so reads\n * fall back to the in-code default value and watchers of `key` receive that default.\n */\n removeValue(key: string): void;\n\n /**\n * Replaces every stored value with `values`, disarms any armed hold or failure, and, when the\n * client is connected, delivers the new values as a full update.\n */\n replaceValues(values: TestValues): void;\n\n /**\n * Makes the next `initialize` wait until {@link completeInitialization} or\n * {@link failInitialization} is called, or until the client's timeout elapses.\n */\n holdInitialization(): void;\n\n /**\n * Delivers the stored values to a held `initialize`, so it completes with the client ready. When\n * a hold is armed but no `initialize` has started, it disarms the hold instead.\n */\n completeInitialization(): void;\n\n /**\n * Fails a held `initialize` with an unrecoverable connection error, or arms the next `initialize`\n * to fail. `initialize` completes promptly with the client not ready and `connectionError` fires.\n */\n failInitialization(): void;\n}\n\nclass InMemoryTestClient implements TestClient {\n constructor(\n public readonly client: ConfigDirectorClient,\n private readonly connection: InMemoryConnection,\n ) {}\n\n public setValue(key: string, value: TestValue) {\n this.connection.setValue(key, value);\n }\n\n public removeValue(key: string) {\n this.connection.removeValue(key);\n }\n\n public replaceValues(values: TestValues) {\n this.connection.replaceValues(values);\n }\n\n public holdInitialization() {\n this.connection.hold();\n }\n\n public completeInitialization() {\n this.connection.complete();\n }\n\n public failInitialization() {\n this.connection.fail();\n }\n}\n\nexport const createTestClient = (sdkOptions: IdentifyingSdkOptions, options?: TestClientOptions): TestClient => {\n const logger = options?.logger ?? createDefaultLogger();\n const connection = new InMemoryConnection(logger, options?.values ?? {});\n const client = new DefaultConfigDirectorClient(\n TEST_CLIENT_SDK_KEY,\n sdkOptions,\n { logger, connection: { timeout: options?.timeout } },\n { transport: connection, telemetry: discardingTelemetryClient },\n );\n return new InMemoryTestClient(client, connection);\n};\n","import { createTestClient as createInMemoryTestClient } from \"./testing/TestClient\";\nimport type { TestClient, TestClientOptions } from \"./testing/TestClient\";\n\nexport type { TestClient, TestClientOptions } from \"./testing/TestClient\";\nexport type { TestValue, TestValues, TestJsonValue } from \"./testing/values\";\nexport { ConfigDirectorConnectionError, ConfigDirectorValidationError } from \"@shared/errors\";\n\n/**\n * Creates a {@link TestClient}: a real `ConfigDirectorClient` connected to an in-memory server\n * that the test controls. No network connection is opened and no telemetry is sent.\n *\n * @param options {@link TestClientOptions}: the initial values, the client's timeout, and its logger\n * @returns A {@link TestClient} whose `client` is passed to the code under test\n *\n * @example\n * import { createTestClient } from \"@configdirector/server-sdk/testing\";\n *\n * const testClient = createTestClient({ values: { \"new-checkout\": true } });\n * await testClient.client.initialize();\n * expect(testClient.client.getValue(\"new-checkout\", false)).toBe(true);\n *\n * testClient.setValue(\"new-checkout\", false);\n */\nexport const createTestClient = (options?: TestClientOptions): TestClient => {\n return createInMemoryTestClient({ sdkName: \"js-server-sdk\", sdkVersion: \"__VERSION__\" }, options);\n};\n"],"mappings":"mHAcA,MAAM,EAAm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AAiB,WAAY,SAAe,CAAE,EAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./DefaultConfigDirectorClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./DefaultConfigDirectorClient-BoqR23zq.cjs`),t={sdkName:`js-server-sdk`,sdkVersion:`1.11.0`};function n(n,r){return e.t.from(n,t,r)}const r=(t,n)=>e.r(t,n);exports.ConfigDirectorInitializationError=e.o,exports.createClient=n,exports.createConsoleLogger=r;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { _ as ConfigValueType, a as ConfigDirectorClientOptions, c as OfflineValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue } from "./errors-C7n65Oc5.cjs";
|
|
2
2
|
|
|
3
3
|
//#region ../shared/src/logger.d.ts
|
|
4
4
|
declare class DefaultConsoleLogger implements ConfigDirectorLogger {
|
|
@@ -39,8 +39,31 @@ declare class DefaultConsoleLogger implements ConfigDirectorLogger {
|
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
|
-
declare
|
|
42
|
+
declare function createClient(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions): ConfigDirectorClient;
|
|
43
|
+
/**
|
|
44
|
+
* Instantiates a ConfigDirector client in `offline` mode, which needs no server SDK key. The client never
|
|
45
|
+
* connects to ConfigDirector: it serves the values of `connection.file` or `connection.values` to every
|
|
46
|
+
* context, or the in-code default values when neither is given. `initialize` rejects with a
|
|
47
|
+
* `ConfigDirectorInitializationError` when the file or the values cannot be loaded.
|
|
48
|
+
*
|
|
49
|
+
* @param clientOptions {@link OfflineClientOptions} - Configuration options for the client, with
|
|
50
|
+
* `connection.mode` set to `offline`.
|
|
51
|
+
* @returns An uninitialized {@link ConfigDirectorClient} instance
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
* import { createClient } from "@configdirector/server-sdk";
|
|
57
|
+
*
|
|
58
|
+
* const client = createClient({
|
|
59
|
+
* connection: { mode: "offline", file: "./flags/new-checkout-on.json" },
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* await client.initialize();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare function createClient(clientOptions: OfflineClientOptions): ConfigDirectorClient;
|
|
43
66
|
declare const createConsoleLogger: (level: ConfigDirectorLoggingLevel, messageDecorator?: ConfigDirectorLogMessageDecorator) => DefaultConsoleLogger;
|
|
44
67
|
//#endregion
|
|
45
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, type ConfigDirectorMetaContext, type ConfigValueType, createClient, createConsoleLogger };
|
|
68
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, type ConfigDirectorMetaContext, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues, createClient, createConsoleLogger };
|
|
46
69
|
//# sourceMappingURL=configdirector-server.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-server.d.cts","names":[],"sources":["../../shared/src/logger.ts","../src/api.ts"],"mappings":";;;cA+Ba,oBAAA,YAAgC,oBAAA;EAAA,iBAGd,KAAA;EAAA,iBAAoD,SAAA;EAAA,iBAFhE,aAAA;cAEY,KAAA,EAAO,0BAAA,EAA6C,SAAA,EAAW,iCAAA;EAM5F,KAAA,CAAM,OAAA,aAAoB,IAAA;EAI1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,KAAA,CAAM,OAAA,aAAoB,IAAA;EAAA,UAIhB,GAAA,CAAI,cAAA,MAAoB,IAAA,gBAAoB,KAAA,EAAO,0BAAA,EAA4B,OAAA,aAAoB,IAAA;AAAA;;;;AAzB/G;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"configdirector-server.d.cts","names":[],"sources":["../../shared/src/logger.ts","../src/api.ts"],"mappings":";;;cA+Ba,oBAAA,YAAgC,oBAAA;EAAA,iBAGd,KAAA;EAAA,iBAAoD,SAAA;EAAA,iBAFhE,aAAA;cAEY,KAAA,EAAO,0BAAA,EAA6C,SAAA,EAAW,iCAAA;EAM5F,KAAA,CAAM,OAAA,aAAoB,IAAA;EAI1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,KAAA,CAAM,OAAA,aAAoB,IAAA;EAAA,UAIhB,GAAA,CAAI,cAAA,MAAoB,IAAA,gBAAoB,KAAA,EAAO,0BAAA,EAA4B,OAAA,aAAoB,IAAA;AAAA;;;;AAzB/G;;;;;;;;;;;;;;;;;;;;;;;;iBCCgB,YAAA,CAAa,YAAA,UAAsB,aAAA,GAAgB,2BAAA,GAA8B,oBAAA;;;;;;;;;;;;;;;;;;AAAjG;;;;;iBAuBgB,YAAA,CAAa,aAAA,EAAe,oBAAA,GAAuB,oBAAA;AAAA,cAQtD,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { _ as ConfigValueType, a as ConfigDirectorClientOptions, c as OfflineValues, f as ConfigDirectorContext, g as ConfigDirectorMetaContext, h as ConfigDirectorLoggingLevel, i as ConfigDirectorClient, m as ConfigDirectorLogger, n as ConfigDirectorInitializationError, o as OfflineClientOptions, p as ConfigDirectorLogMessageDecorator, s as OfflineValue } from "./errors-BCEfxVqM.mjs";
|
|
2
2
|
|
|
3
3
|
//#region ../shared/src/logger.d.ts
|
|
4
4
|
declare class DefaultConsoleLogger implements ConfigDirectorLogger {
|
|
@@ -39,8 +39,31 @@ declare class DefaultConsoleLogger implements ConfigDirectorLogger {
|
|
|
39
39
|
* ```
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
|
-
declare
|
|
42
|
+
declare function createClient(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions): ConfigDirectorClient;
|
|
43
|
+
/**
|
|
44
|
+
* Instantiates a ConfigDirector client in `offline` mode, which needs no server SDK key. The client never
|
|
45
|
+
* connects to ConfigDirector: it serves the values of `connection.file` or `connection.values` to every
|
|
46
|
+
* context, or the in-code default values when neither is given. `initialize` rejects with a
|
|
47
|
+
* `ConfigDirectorInitializationError` when the file or the values cannot be loaded.
|
|
48
|
+
*
|
|
49
|
+
* @param clientOptions {@link OfflineClientOptions} - Configuration options for the client, with
|
|
50
|
+
* `connection.mode` set to `offline`.
|
|
51
|
+
* @returns An uninitialized {@link ConfigDirectorClient} instance
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* ```
|
|
56
|
+
* import { createClient } from "@configdirector/server-sdk";
|
|
57
|
+
*
|
|
58
|
+
* const client = createClient({
|
|
59
|
+
* connection: { mode: "offline", file: "./flags/new-checkout-on.json" },
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* await client.initialize();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare function createClient(clientOptions: OfflineClientOptions): ConfigDirectorClient;
|
|
43
66
|
declare const createConsoleLogger: (level: ConfigDirectorLoggingLevel, messageDecorator?: ConfigDirectorLogMessageDecorator) => DefaultConsoleLogger;
|
|
44
67
|
//#endregion
|
|
45
|
-
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, type ConfigDirectorMetaContext, type ConfigValueType, createClient, createConsoleLogger };
|
|
68
|
+
export { type ConfigDirectorClient, type ConfigDirectorClientOptions, type ConfigDirectorContext, ConfigDirectorInitializationError, type ConfigDirectorLogMessageDecorator, type ConfigDirectorLogger, type ConfigDirectorLoggingLevel, type ConfigDirectorMetaContext, type ConfigValueType, type OfflineClientOptions, type OfflineValue, type OfflineValues, createClient, createConsoleLogger };
|
|
46
69
|
//# sourceMappingURL=configdirector-server.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-server.d.mts","names":[],"sources":["../../shared/src/logger.ts","../src/api.ts"],"mappings":";;;cA+Ba,oBAAA,YAAgC,oBAAA;EAAA,iBAGd,KAAA;EAAA,iBAAoD,SAAA;EAAA,iBAFhE,aAAA;cAEY,KAAA,EAAO,0BAAA,EAA6C,SAAA,EAAW,iCAAA;EAM5F,KAAA,CAAM,OAAA,aAAoB,IAAA;EAI1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,KAAA,CAAM,OAAA,aAAoB,IAAA;EAAA,UAIhB,GAAA,CAAI,cAAA,MAAoB,IAAA,gBAAoB,KAAA,EAAO,0BAAA,EAA4B,OAAA,aAAoB,IAAA;AAAA;;;;AAzB/G;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"configdirector-server.d.mts","names":[],"sources":["../../shared/src/logger.ts","../src/api.ts"],"mappings":";;;cA+Ba,oBAAA,YAAgC,oBAAA;EAAA,iBAGd,KAAA;EAAA,iBAAoD,SAAA;EAAA,iBAFhE,aAAA;cAEY,KAAA,EAAO,0BAAA,EAA6C,SAAA,EAAW,iCAAA;EAM5F,KAAA,CAAM,OAAA,aAAoB,IAAA;EAI1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAIzB,KAAA,CAAM,OAAA,aAAoB,IAAA;EAAA,UAIhB,GAAA,CAAI,cAAA,MAAoB,IAAA,gBAAoB,KAAA,EAAO,0BAAA,EAA4B,OAAA,aAAoB,IAAA;AAAA;;;;AAzB/G;;;;;;;;;;;;;;;;;;;;;;;;iBCCgB,YAAA,CAAa,YAAA,UAAsB,aAAA,GAAgB,2BAAA,GAA8B,oBAAA;;;;;;;;;;;;;;;;;;AAAjG;;;;;iBAuBgB,YAAA,CAAa,aAAA,EAAe,oBAAA,GAAuB,oBAAA;AAAA,cAQtD,mBAAA,GACX,KAAA,EAAO,0BAAA,EACP,gBAAA,GAAmB,iCAAA,KAAiC,oBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o as e,r as t,t as n}from"./DefaultConfigDirectorClient-z8HbdUmy.mjs";const r={sdkName:`js-server-sdk`,sdkVersion:`1.11.0`};function i(e,t){return n.from(e,r,t)}const a=(e,n)=>t(e,n);export{e as ConfigDirectorInitializationError,i as createClient,a as createConsoleLogger};
|
|
2
2
|
//# sourceMappingURL=configdirector-server.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configdirector-server.mjs","names":[],"sources":["../src/api.ts"],"sourcesContent":["import type { ConfigDirectorLoggingLevel, ConfigDirectorLogMessageDecorator } from \"@shared/types\";\nimport { DefaultConfigDirectorClient } from \"./DefaultConfigDirectorClient\";\nimport type { ConfigDirectorClient, ConfigDirectorClientOptions } from \"./types\";\nimport { createDefaultLogger } from \"./logger\";\n\n/**\n * Instantiates a ConfigDirector client to be used in a server environment. This function returns an\n * uninitialized client and does not make any network calls. You must call {@link ConfigDirectorClient.initialize}\n * before the client is ready to use:\n *\n * @param serverSdkKey string - The ConfigDirector server SDK key. This is a secret value, do not commit it\n * in your source code.\n * @param clientOptions {@link ConfigDirectorClientOptions} - Configuration options for the client (optional).\n * It is recommended that you include the {@link ConfigDirectorClientOptions.metadata} option including your `appName` and `appVersion` in order\n * to use those values in targeting rules.\n * @returns An uninitialized {@link ConfigDirectorClient} instance\n *\n * @example\n *\n * ```\n * import { createClient } from \"@configdirector/server-sdk\";\n *\n * const client = createClient(\"YOUR-SERVER-SDK-KEY\", {\n * metadata: { appName: \"my-awesome-app\", appVersion: \"1.0.0\" }\n * });\n *\n * await client.initialize();\n * ```\n *\n */\nexport
|
|
1
|
+
{"version":3,"file":"configdirector-server.mjs","names":[],"sources":["../src/api.ts"],"sourcesContent":["import type { ConfigDirectorLoggingLevel, ConfigDirectorLogMessageDecorator } from \"@shared/types\";\nimport { DefaultConfigDirectorClient } from \"./DefaultConfigDirectorClient\";\nimport type { ConfigDirectorClient, ConfigDirectorClientOptions, OfflineClientOptions } from \"./types\";\nimport { createDefaultLogger } from \"./logger\";\n\nconst SDK_IDENTITY = { sdkName: \"js-server-sdk\", sdkVersion: \"__VERSION__\" };\n\n/**\n * Instantiates a ConfigDirector client to be used in a server environment. This function returns an\n * uninitialized client and does not make any network calls. You must call {@link ConfigDirectorClient.initialize}\n * before the client is ready to use:\n *\n * @param serverSdkKey string - The ConfigDirector server SDK key. This is a secret value, do not commit it\n * in your source code.\n * @param clientOptions {@link ConfigDirectorClientOptions} - Configuration options for the client (optional).\n * It is recommended that you include the {@link ConfigDirectorClientOptions.metadata} option including your `appName` and `appVersion` in order\n * to use those values in targeting rules.\n * @returns An uninitialized {@link ConfigDirectorClient} instance\n *\n * @example\n *\n * ```\n * import { createClient } from \"@configdirector/server-sdk\";\n *\n * const client = createClient(\"YOUR-SERVER-SDK-KEY\", {\n * metadata: { appName: \"my-awesome-app\", appVersion: \"1.0.0\" }\n * });\n *\n * await client.initialize();\n * ```\n *\n */\nexport function createClient(serverSdkKey: string, clientOptions?: ConfigDirectorClientOptions): ConfigDirectorClient;\n/**\n * Instantiates a ConfigDirector client in `offline` mode, which needs no server SDK key. The client never\n * connects to ConfigDirector: it serves the values of `connection.file` or `connection.values` to every\n * context, or the in-code default values when neither is given. `initialize` rejects with a\n * `ConfigDirectorInitializationError` when the file or the values cannot be loaded.\n *\n * @param clientOptions {@link OfflineClientOptions} - Configuration options for the client, with\n * `connection.mode` set to `offline`.\n * @returns An uninitialized {@link ConfigDirectorClient} instance\n *\n * @example\n *\n * ```\n * import { createClient } from \"@configdirector/server-sdk\";\n *\n * const client = createClient({\n * connection: { mode: \"offline\", file: \"./flags/new-checkout-on.json\" },\n * });\n *\n * await client.initialize();\n * ```\n */\nexport function createClient(clientOptions: OfflineClientOptions): ConfigDirectorClient;\nexport function createClient(\n serverSdkKeyOrOptions: string | OfflineClientOptions,\n clientOptions?: ConfigDirectorClientOptions,\n): ConfigDirectorClient {\n return DefaultConfigDirectorClient.from(serverSdkKeyOrOptions, SDK_IDENTITY, clientOptions);\n}\n\nexport const createConsoleLogger = (\n level: ConfigDirectorLoggingLevel,\n messageDecorator?: ConfigDirectorLogMessageDecorator,\n) => {\n return createDefaultLogger(level, messageDecorator);\n};\n"],"mappings":"6EAKA,MAAM,EAAe,CAAE,QAAS,gBAAiB,WAAY,SAAe,CAmD5E,SAAgB,EACd,EACA,EACsB,CACtB,OAAO,EAA4B,KAAK,EAAuB,EAAc,EAAc,CAG7F,MAAa,GACX,EACA,IAEO,EAAoB,EAAO,EAAiB"}
|
|
@@ -87,9 +87,90 @@ type ConfigDirectorMetaContext = {
|
|
|
87
87
|
appVersion?: string;
|
|
88
88
|
appName?: string;
|
|
89
89
|
};
|
|
90
|
-
type ConnectionMode = "streaming" | "polling";
|
|
90
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../shared/src/native-values.d.ts
|
|
93
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
94
|
+
[key: string]: NativeJsonValue;
|
|
95
|
+
};
|
|
96
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
97
|
+
[key: string]: NativeJsonValue;
|
|
98
|
+
};
|
|
99
|
+
type NativeValues = Record<string, NativeValue>;
|
|
91
100
|
//#endregion
|
|
92
101
|
//#region src/types.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
104
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
105
|
+
* or array (`json`).
|
|
106
|
+
*/
|
|
107
|
+
type OfflineValue = NativeValue;
|
|
108
|
+
/**
|
|
109
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
110
|
+
* value's config type is decided. Every context receives the same value.
|
|
111
|
+
*/
|
|
112
|
+
type OfflineValues = NativeValues;
|
|
113
|
+
/**
|
|
114
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
115
|
+
*/
|
|
116
|
+
type ConnectionOptions = {
|
|
117
|
+
/**
|
|
118
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
119
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
120
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
121
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
122
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
123
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
124
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
125
|
+
* default values when neither is given. No SDK key is needed.
|
|
126
|
+
*
|
|
127
|
+
* Defaults to `streaming`
|
|
128
|
+
*/
|
|
129
|
+
mode?: ConnectionMode;
|
|
130
|
+
/**
|
|
131
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
132
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
133
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
134
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
135
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
136
|
+
*
|
|
137
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
138
|
+
* `initialize` rejects.
|
|
139
|
+
*/
|
|
140
|
+
file?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
143
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
144
|
+
*
|
|
145
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
146
|
+
* `initialize` rejects.
|
|
147
|
+
*/
|
|
148
|
+
values?: OfflineValues;
|
|
149
|
+
/**
|
|
150
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
151
|
+
* effect in the other modes.
|
|
152
|
+
*
|
|
153
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
154
|
+
* raised to the minimum and a warning is logged.
|
|
155
|
+
*/
|
|
156
|
+
pollingInterval?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
159
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
160
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
161
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
162
|
+
* no effect in `offline` mode.
|
|
163
|
+
*
|
|
164
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
165
|
+
*/
|
|
166
|
+
timeout?: number;
|
|
167
|
+
/**
|
|
168
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
169
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
170
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
171
|
+
*/
|
|
172
|
+
url?: string;
|
|
173
|
+
};
|
|
93
174
|
/**
|
|
94
175
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
95
176
|
*/
|
|
@@ -101,41 +182,7 @@ type ConfigDirectorClientOptions = {
|
|
|
101
182
|
/**
|
|
102
183
|
* Connection options
|
|
103
184
|
*/
|
|
104
|
-
connection?:
|
|
105
|
-
/**
|
|
106
|
-
* The connection mode to be used, one of `streaming` (default) or `polling`.
|
|
107
|
-
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
108
|
-
* config state is updated on the ConfigDirector dashboard.
|
|
109
|
-
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
110
|
-
* initialization, and additional requests on a `pollingInterval`.
|
|
111
|
-
*
|
|
112
|
-
* Defaults to `streaming`
|
|
113
|
-
*/
|
|
114
|
-
mode?: ConnectionMode;
|
|
115
|
-
/**
|
|
116
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
117
|
-
* effect when the `mode` is set to `streaming`.
|
|
118
|
-
*
|
|
119
|
-
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
120
|
-
* raised to the minimum and a warning is logged.
|
|
121
|
-
*/
|
|
122
|
-
pollingInterval?: number;
|
|
123
|
-
/**
|
|
124
|
-
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
125
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
126
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
127
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
128
|
-
*
|
|
129
|
-
* Defaults to 3,000 milliseconds (3 seconds)
|
|
130
|
-
*/
|
|
131
|
-
timeout?: number;
|
|
132
|
-
/**
|
|
133
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
134
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
135
|
-
* a proxy for the client SDK.
|
|
136
|
-
*/
|
|
137
|
-
url?: string;
|
|
138
|
-
};
|
|
185
|
+
connection?: ConnectionOptions;
|
|
139
186
|
/**
|
|
140
187
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
141
188
|
* logger set to 'warn' level.
|
|
@@ -195,6 +242,14 @@ type ConfigDirectorClientOptions = {
|
|
|
195
242
|
*/
|
|
196
243
|
hooks?: ClientHooks;
|
|
197
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
247
|
+
*/
|
|
248
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
249
|
+
connection: ConnectionOptions & {
|
|
250
|
+
mode: "offline";
|
|
251
|
+
};
|
|
252
|
+
};
|
|
198
253
|
type ClientEvents = {
|
|
199
254
|
configsUpdated: {
|
|
200
255
|
keys: string[];
|
|
@@ -301,5 +356,20 @@ interface ConfigDirectorClient {
|
|
|
301
356
|
dispose(): void;
|
|
302
357
|
}
|
|
303
358
|
//#endregion
|
|
304
|
-
|
|
305
|
-
|
|
359
|
+
//#region ../shared/src/errors.d.ts
|
|
360
|
+
declare class ConfigDirectorConnectionError extends Error {
|
|
361
|
+
readonly name: string;
|
|
362
|
+
readonly status?: number;
|
|
363
|
+
constructor(message: string, status?: number);
|
|
364
|
+
}
|
|
365
|
+
declare class ConfigDirectorValidationError extends Error {
|
|
366
|
+
readonly name: string;
|
|
367
|
+
constructor(message: string);
|
|
368
|
+
}
|
|
369
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
370
|
+
readonly name: string;
|
|
371
|
+
constructor(message: string);
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { ConfigValueType as _, ConfigDirectorClientOptions as a, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u };
|
|
375
|
+
//# sourceMappingURL=errors-BCEfxVqM.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BCEfxVqM.d.mts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../src/types.ts","../../shared/src/errors.ts"],"mappings":";cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;AAAA,KAGN,gBAAA;AAAA,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;AA9BZ;;;KAqCY,qBAAA;EApCV;;;;;;;;EA6CA,EAAA;EAvCA;;;;;AAGF;;;;;AAIA;EA6CE,IAAA;;;;AAnCF;EAyCE,IAAA;;;;;EAMA,MAAA;IAAA,CAAY,GAAA;EAAA;EA7CZ;;;;;;;EAsDA,SAAA;AAAA;;AA3CF;;;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA;;;KCxHA,eAAA,sCAAqD,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE1F,WAAA,+BAA0C,eAAA;EAAA,CAAuB,GAAA,WAAc,eAAA;AAAA;AAAA,KAE/E,YAAA,GAAe,MAAA,SAAe,WAAA;;;;ADG1C;;;;KEqBY,YAAA,GAAe,WAAA;AFnB3B;;;;AAAA,KEyBY,a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OAAA;EAnCd;;;;;;EAAA,IA2CI,OAAA;EAxCJ;;;;;AAGF;;;;;EAiDE,QAAA,WAAmB,eAAA,EAAiB,SAAA,UAAmB,YAAA,EAAc,CAAA,EAAG,OAAA,GAAU,qBAAA,GAAwB,CAAA;EA/CzD;;;;;;;;;;;;EA6DjD,KAAA,WAAgB,eAAA,EACd,SAAA,UACA,YAAA,EAAc,CAAA,EACd,QAAA,EAAU,YAAA,CAAa,CAAA,GACvB,OAAA,GAAU,qBAAA;EAhEZ;;;;;;;;EA2EA,OAAA,WAAkB,eAAA,EAAiB,SAAA,UAAmB,QAAA,GAAW,YAAA,CAAa,CAAA;EAvEzD;;;EA4ErB,UAAA;EA5EkF;;;;;;;EAqFlF,aAAA,CAAc,OAAA;IACZ,OAAA,GAAU,qBAAA;IACV,UAAA;EAAA,IACE,MAAA,SAAe,WAAA;EAEnB,EAAA,iBAAmB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,GAAU,IAAA,EAAM,YAAA,CAAa,CAAA;EAE5E,GAAA,iBAAoB,YAAA,EAAc,SAAA,EAAW,CAAA,EAAG,OAAA,IAAW,IAAA,EAAM,YAAA,CAAa,CAAA;EA1Ff;;;;;;EAkG/D,OAAA;AAAA;;;cCzSW,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;EAAA,SACT,MAAA;cAEJ,OAAA,UAAiB,MAAA;AAAA;AAAA,cAQlB,6BAAA,SAAsC,KAAA;EAAA,SACxB,IAAA;cAEb,OAAA;AAAA;AAAA,cAOD,iCAAA,SAA0C,KAAA;EAAA,SAC5B,IAAA;cAEb,OAAA;AAAA"}
|
|
@@ -87,9 +87,90 @@ type ConfigDirectorMetaContext = {
|
|
|
87
87
|
appVersion?: string;
|
|
88
88
|
appName?: string;
|
|
89
89
|
};
|
|
90
|
-
type ConnectionMode = "streaming" | "polling";
|
|
90
|
+
type ConnectionMode = "streaming" | "polling" | "offline";
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region ../shared/src/native-values.d.ts
|
|
93
|
+
type NativeJsonValue = boolean | number | string | null | NativeJsonValue[] | {
|
|
94
|
+
[key: string]: NativeJsonValue;
|
|
95
|
+
};
|
|
96
|
+
type NativeValue = boolean | number | string | NativeJsonValue[] | {
|
|
97
|
+
[key: string]: NativeJsonValue;
|
|
98
|
+
};
|
|
99
|
+
type NativeValues = Record<string, NativeValue>;
|
|
91
100
|
//#endregion
|
|
92
101
|
//#region src/types.d.ts
|
|
102
|
+
/**
|
|
103
|
+
* One value an offline client serves for a config key. The config type follows from the value: a
|
|
104
|
+
* boolean, an integral number (`integer`), any other number (`float`), a string, or a plain object
|
|
105
|
+
* or array (`json`).
|
|
106
|
+
*/
|
|
107
|
+
type OfflineValue = NativeValue;
|
|
108
|
+
/**
|
|
109
|
+
* The values an offline client serves, keyed by config key. See {@link OfflineValue} for how each
|
|
110
|
+
* value's config type is decided. Every context receives the same value.
|
|
111
|
+
*/
|
|
112
|
+
type OfflineValues = NativeValues;
|
|
113
|
+
/**
|
|
114
|
+
* Connection options of the {@link ConfigDirectorClient}
|
|
115
|
+
*/
|
|
116
|
+
type ConnectionOptions = {
|
|
117
|
+
/**
|
|
118
|
+
* The connection mode to be used, one of `streaming` (default), `polling` or `offline`.
|
|
119
|
+
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
120
|
+
* config state is updated on the ConfigDirector dashboard.
|
|
121
|
+
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
122
|
+
* initialization, and additional requests on a `pollingInterval`.
|
|
123
|
+
* When set to `offline`, the client never connects to ConfigDirector and sends nothing: it serves
|
|
124
|
+
* the values read from {@link file} or given in {@link values} to every context, or the in-code
|
|
125
|
+
* default values when neither is given. No SDK key is needed.
|
|
126
|
+
*
|
|
127
|
+
* Defaults to `streaming`
|
|
128
|
+
*/
|
|
129
|
+
mode?: ConnectionMode;
|
|
130
|
+
/**
|
|
131
|
+
* The path of a JSON file holding the values to serve in `offline` mode, resolved against the
|
|
132
|
+
* process working directory. The file holds one object with a value per config key, such as
|
|
133
|
+
* `{ "new-checkout": true, "max-items": 20 }`; see {@link OfflineValue} for how the config type
|
|
134
|
+
* of each value is decided. A file that is missing, unreadable, not a JSON object, or holding a
|
|
135
|
+
* value such as `null` makes `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
136
|
+
*
|
|
137
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
138
|
+
* `initialize` rejects.
|
|
139
|
+
*/
|
|
140
|
+
file?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The values to serve in `offline` mode, keyed by config key. A value such as `null` makes
|
|
143
|
+
* `initialize` reject with a `ConfigDirectorInitializationError`.
|
|
144
|
+
*
|
|
145
|
+
* Only one of `file` and `values` can be given, and only in `offline` mode; otherwise
|
|
146
|
+
* `initialize` rejects.
|
|
147
|
+
*/
|
|
148
|
+
values?: OfflineValues;
|
|
149
|
+
/**
|
|
150
|
+
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
151
|
+
* effect in the other modes.
|
|
152
|
+
*
|
|
153
|
+
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
154
|
+
* raised to the minimum and a warning is logged.
|
|
155
|
+
*/
|
|
156
|
+
pollingInterval?: number;
|
|
157
|
+
/**
|
|
158
|
+
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
159
|
+
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
160
|
+
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
161
|
+
* If streaming is disabled, if the operation times out, it will not be retried. This option has
|
|
162
|
+
* no effect in `offline` mode.
|
|
163
|
+
*
|
|
164
|
+
* Defaults to 3,000 milliseconds (3 seconds)
|
|
165
|
+
*/
|
|
166
|
+
timeout?: number;
|
|
167
|
+
/**
|
|
168
|
+
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
169
|
+
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
170
|
+
* a proxy for the client SDK. This option has no effect in `offline` mode.
|
|
171
|
+
*/
|
|
172
|
+
url?: string;
|
|
173
|
+
};
|
|
93
174
|
/**
|
|
94
175
|
* Configuration options for the {@link ConfigDirectorClient}
|
|
95
176
|
*/
|
|
@@ -101,41 +182,7 @@ type ConfigDirectorClientOptions = {
|
|
|
101
182
|
/**
|
|
102
183
|
* Connection options
|
|
103
184
|
*/
|
|
104
|
-
connection?:
|
|
105
|
-
/**
|
|
106
|
-
* The connection mode to be used, one of `streaming` (default) or `polling`.
|
|
107
|
-
* If set to `streaming`, the connection will remain open and receive updates whenever
|
|
108
|
-
* config state is updated on the ConfigDirector dashboard.
|
|
109
|
-
* When set to `polling`, there will be an initial request to retrieve config state during
|
|
110
|
-
* initialization, and additional requests on a `pollingInterval`.
|
|
111
|
-
*
|
|
112
|
-
* Defaults to `streaming`
|
|
113
|
-
*/
|
|
114
|
-
mode?: ConnectionMode;
|
|
115
|
-
/**
|
|
116
|
-
* The polling interval in _seconds_ when the `mode` is set to `polling`. This option has no
|
|
117
|
-
* effect when the `mode` is set to `streaming`.
|
|
118
|
-
*
|
|
119
|
-
* Defaults to 300 seconds (5 minutes). The minimum is 60 seconds. A value below the minimum is
|
|
120
|
-
* raised to the minimum and a warning is logged.
|
|
121
|
-
*/
|
|
122
|
-
pollingInterval?: number;
|
|
123
|
-
/**
|
|
124
|
-
* The timeout, in milliseconds, to be used in initialization and when updating the context.
|
|
125
|
-
* If streaming is enabled, the operation (initialization or context update) may still succeed
|
|
126
|
-
* after it times out if no unrecoverable errors are encountered (like an invalid SDK key).
|
|
127
|
-
* If streaming is disabled, if the operation times out, it will not be retried.
|
|
128
|
-
*
|
|
129
|
-
* Defaults to 3,000 milliseconds (3 seconds)
|
|
130
|
-
*/
|
|
131
|
-
timeout?: number;
|
|
132
|
-
/**
|
|
133
|
-
* The base URL to the ConfigDirector SDK server. To be used only when needing to route through a
|
|
134
|
-
* proxy to connect to the ConfigDirector SDK server. Please refer to the docs on how to configure
|
|
135
|
-
* a proxy for the client SDK.
|
|
136
|
-
*/
|
|
137
|
-
url?: string;
|
|
138
|
-
};
|
|
185
|
+
connection?: ConnectionOptions;
|
|
139
186
|
/**
|
|
140
187
|
* A logger that implements {@link ConfigDirectorLogger}. It defaults to the ConfigDirector console
|
|
141
188
|
* logger set to 'warn' level.
|
|
@@ -195,6 +242,14 @@ type ConfigDirectorClientOptions = {
|
|
|
195
242
|
*/
|
|
196
243
|
hooks?: ClientHooks;
|
|
197
244
|
};
|
|
245
|
+
/**
|
|
246
|
+
* The options of a client created without an SDK key: the connection mode is `offline`.
|
|
247
|
+
*/
|
|
248
|
+
type OfflineClientOptions = ConfigDirectorClientOptions & {
|
|
249
|
+
connection: ConnectionOptions & {
|
|
250
|
+
mode: "offline";
|
|
251
|
+
};
|
|
252
|
+
};
|
|
198
253
|
type ClientEvents = {
|
|
199
254
|
configsUpdated: {
|
|
200
255
|
keys: string[];
|
|
@@ -301,5 +356,20 @@ interface ConfigDirectorClient {
|
|
|
301
356
|
dispose(): void;
|
|
302
357
|
}
|
|
303
358
|
//#endregion
|
|
304
|
-
|
|
305
|
-
|
|
359
|
+
//#region ../shared/src/errors.d.ts
|
|
360
|
+
declare class ConfigDirectorConnectionError extends Error {
|
|
361
|
+
readonly name: string;
|
|
362
|
+
readonly status?: number;
|
|
363
|
+
constructor(message: string, status?: number);
|
|
364
|
+
}
|
|
365
|
+
declare class ConfigDirectorValidationError extends Error {
|
|
366
|
+
readonly name: string;
|
|
367
|
+
constructor(message: string);
|
|
368
|
+
}
|
|
369
|
+
declare class ConfigDirectorInitializationError extends Error {
|
|
370
|
+
readonly name: string;
|
|
371
|
+
constructor(message: string);
|
|
372
|
+
}
|
|
373
|
+
//#endregion
|
|
374
|
+
export { ConfigValueType as _, ConfigDirectorClientOptions as a, OfflineValues as c, NativeValues as d, ConfigDirectorContext as f, ConfigDirectorMetaContext as g, ConfigDirectorLoggingLevel as h, ConfigDirectorClient as i, NativeJsonValue as l, ConfigDirectorLogger as m, ConfigDirectorInitializationError as n, OfflineClientOptions as o, ConfigDirectorLogMessageDecorator as p, ConfigDirectorValidationError as r, OfflineValue as s, ConfigDirectorConnectionError as t, NativeValue as u };
|
|
375
|
+
//# sourceMappingURL=errors-C7n65Oc5.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-C7n65Oc5.d.cts","names":[],"sources":["../../shared/src/types.ts","../../shared/src/native-values.ts","../src/types.ts","../../shared/src/errors.ts"],"mappings":";cAAa,cAAA;AAAA,KAUD,UAAA,WAAqB,cAAA;AAAA,KAErB,kBAAA;EAAA,CAAwB,GAAA;AAAA;AAAA,KAExB,eAAA,wCAAuD,kBAAA;AAAA,KAEvD,WAAA;EACV,EAAA;EACA,GAAA;EACA,IAAA,EAAM,UAAA;EACN,KAAA;EACA,OAAA;AAAA;AAAA,KAQU,0BAAA;AAAA,UAEK,oBAAA;EACf,KAAA,CAAM,OAAA,aAAoB,IAAA;EAE1B,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,IAAA,CAAK,OAAA,aAAoB,IAAA;EAEzB,KAAA,CAAM,OAAA,aAAoB,IAAA;AAAA;AAAA,UAGX,iCAAA;EACf,eAAA,CAAgB,OAAA;AAAA;AAAA,KAGN,gBAAA;AAAA,KAUA,gBAAA;EACV,GAAA;EACA,KAAA,EAAO,eAAA;EACP,OAAA;EACA,cAAA;EACA,MAAA,EAAQ,gBAAA;EACR,OAAA,GAAU,qBAAA;AAAA;;;AA9BZ;;;KAqCY,qBAAA;EApCV;;;;;;;;EA6CA,EAAA;EAvCA;;;;;AAGF;;;;;AAIA;EA6CE,IAAA;;;;AAnCF;EAyCE,IAAA;;;;;EAMA,MAAA;IAAA,CAAY,GAAA;EAAA;EA7CZ;;;;;;;EAsDA,SAAA;AAAA;;AA3CF;;;KAkDY,yBAAA;EACV,UAAA;EACA,OAAA;AAAA;AAAA,KAGU,cAAA;;;KCxHA,eAAA,sCAAqD,eAAA;E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