@temps-sdk/node-sdk 0.0.7 → 0.1.0-beta.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/analytics/identify.d.ts +72 -0
  2. package/dist/analytics/identify.js +103 -0
  3. package/dist/analytics/index.d.ts +6 -0
  4. package/dist/analytics/index.js +6 -0
  5. package/dist/client/client/client.gen.js +2 -0
  6. package/dist/client/client/index.js +2 -1
  7. package/dist/client/client/types.gen.js +2 -1
  8. package/dist/client/client/utils.gen.js +2 -0
  9. package/dist/client/client.gen.js +2 -1
  10. package/dist/client/core/auth.gen.js +2 -1
  11. package/dist/client/core/bodySerializer.gen.js +2 -1
  12. package/dist/client/core/params.gen.js +2 -1
  13. package/dist/client/core/pathSerializer.gen.js +2 -1
  14. package/dist/client/core/serverSentEvents.gen.js +2 -1
  15. package/dist/client/core/types.gen.js +2 -1
  16. package/dist/client/core/utils.gen.js +2 -1
  17. package/dist/client/index.js +2 -0
  18. package/dist/client/sdk.gen.d.ts +20 -0
  19. package/dist/client/sdk.gen.js +80 -2
  20. package/dist/client/types.gen.d.ts +661 -8
  21. package/dist/client/types.gen.js +2 -1
  22. package/dist/errors/client.js +2 -0
  23. package/dist/errors/hub.js +2 -0
  24. package/dist/errors/index.js +2 -0
  25. package/dist/errors/scope.js +2 -0
  26. package/dist/errors/stacktrace.js +2 -0
  27. package/dist/errors/transaction.js +2 -0
  28. package/dist/errors/transport.js +2 -0
  29. package/dist/errors/types.js +2 -0
  30. package/dist/flags/client.d.ts +0 -11
  31. package/dist/flags/client.js +23 -1
  32. package/dist/flags/evaluate.d.ts +12 -21
  33. package/dist/flags/evaluate.js +252 -22
  34. package/dist/flags/index.js +2 -0
  35. package/dist/flags/sha256.d.ts +4 -0
  36. package/dist/flags/sha256.js +81 -0
  37. package/dist/flags/types.d.ts +57 -14
  38. package/dist/flags/types.js +2 -5
  39. package/dist/index.d.ts +86 -0
  40. package/dist/index.js +9201 -552
  41. package/package.json +8 -3
@@ -7,9 +7,9 @@ export type FlagValueType = 'bool' | 'string' | 'number' | 'json';
7
7
  /**
8
8
  * Why an evaluation produced the value it did.
9
9
  *
10
- * `RULE_MATCH` and `PERCENTAGE_ROLLOUT` are declared because they are part of
11
- * the wire contract, but the server never emits them yet — targeting has not
12
- * shipped. Code that switches on `reason` should handle them from day one.
10
+ * `RULE_MATCH` means targeting rule `index` matched on its conditions;
11
+ * `PERCENTAGE_ROLLOUT` means the subject's bucket decided it (a rollout
12
+ * percentage or a variant split).
13
13
  */
14
14
  export type EvalReason = {
15
15
  kind: 'FLAG_NOT_FOUND';
@@ -28,6 +28,42 @@ export type EvalReason = {
28
28
  } | {
29
29
  kind: 'ERROR';
30
30
  };
31
+ export type AttributeValue = string | number | boolean;
32
+ /** A named value a flag can serve. */
33
+ export interface FlagVariant {
34
+ key: string;
35
+ value: unknown;
36
+ description?: string | null;
37
+ }
38
+ export type ConditionOperator = 'eq' | 'neq' | 'in' | 'not_in' | 'contains' | 'not_contains' | 'matches' | 'gt' | 'gte' | 'lt' | 'lte' | 'exists' | 'not_exists';
39
+ export interface RuleCondition {
40
+ attribute: string;
41
+ operator: ConditionOperator;
42
+ /** Absent for `exists`/`not_exists`; a list for `in`/`not_in`. */
43
+ value?: AttributeValue | AttributeValue[] | null;
44
+ }
45
+ export interface VariantWeight {
46
+ variant: string;
47
+ weight: number;
48
+ }
49
+ export type RuleServe = {
50
+ kind: 'value';
51
+ value: unknown;
52
+ } | {
53
+ kind: 'variant';
54
+ variant: string;
55
+ } | {
56
+ kind: 'split';
57
+ split: VariantWeight[];
58
+ };
59
+ /** `when <all conditions> [within rollout_percentage] serve <serve>`. */
60
+ export interface FlagRule {
61
+ description?: string | null;
62
+ conditions?: RuleCondition[];
63
+ /** 0-100; absent means every matching subject. */
64
+ rollout_percentage?: number | null;
65
+ serve: RuleServe;
66
+ }
31
67
  /** One flag, already resolved down to a single environment. */
32
68
  export interface FlagSnapshot {
33
69
  key: string;
@@ -37,27 +73,30 @@ export interface FlagSnapshot {
37
73
  enabled: boolean;
38
74
  /** `null` means "inherit `default_value`". */
39
75
  environment_value?: unknown | null;
76
+ /** Bucketing salt for rollouts and splits. Server-side only. */
77
+ salt?: string;
78
+ variants?: FlagVariant[];
79
+ /** Ordered targeting rules; first match wins. */
80
+ rules?: FlagRule[];
40
81
  }
41
82
  export interface FlagSnapshotResponse {
42
83
  environment_id: number;
43
84
  flags: FlagSnapshot[];
44
85
  }
45
- /**
46
- * Everything you know about the subject being evaluated.
47
- *
48
- * Accepted and ignored today: targeting has not shipped. It is in the signature
49
- * now so that when it does, you add attributes to a call you have already
50
- * written instead of editing every call site.
51
- */
86
+ /** Everything you know about the subject being evaluated. */
52
87
  export interface EvalContext {
53
- /** Stable bucketing subject (user id, account id, device id). */
88
+ /**
89
+ * Stable bucketing subject (user id, account id, device id). Rules with a
90
+ * rollout below 100% or a variant split are skipped without one; a 100%
91
+ * rollout serving a value or a variant matches without it.
92
+ */
54
93
  key?: string;
55
- /** Targeting attributes, e.g. `{ plan: 'enterprise', region: 'eu' }`. */
56
- attributes?: Record<string, string | number | boolean>;
94
+ /** Targeting attributes, e.g. `{ plan: 'enterprise', country: 'DE' }`. */
95
+ attributes?: Record<string, AttributeValue>;
57
96
  }
58
97
  export interface Evaluation<T> {
59
98
  value: T;
60
- /** Named variant, once variants exist. Always `null` today. */
99
+ /** The variant a targeting rule served, or `null` for plain values. */
61
100
  variant: string | null;
62
101
  reason: EvalReason;
63
102
  }
@@ -80,6 +119,10 @@ export interface FlagsClientOptions {
80
119
  /**
81
120
  * Background refresh interval in milliseconds. Default 30s. Unchanged flags
82
121
  * cost a 304, not a payload.
122
+ *
123
+ * Falls back to `TEMPS_FLAGS_REFRESH_INTERVAL_MS` when unset, so a
124
+ * deployment can tighten (or loosen) polling without a code change or
125
+ * redeploy of the SDK itself — just the env var.
83
126
  */
84
127
  refreshIntervalMs?: number;
85
128
  /** Per-request timeout in milliseconds. Default 5s. */
@@ -1,6 +1,3 @@
1
- /**
2
- * Feature-flag types. These mirror `crates/temps-flags/src/eval.rs` exactly —
3
- * the SDK evaluates locally, so the two implementations must agree or the same
4
- * flag resolves differently on the server and in the app.
5
- */
1
+ // SPDX-FileCopyrightText: 2024-2026 Temps Contributors
2
+ // SPDX-License-Identifier: MIT OR Apache-2.0
6
3
  export {};
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export * from './client/sdk.gen';
5
5
  export * as ErrorTracking from './errors';
6
6
  export * as Flags from './flags';
7
7
  export { FlagsClient, flags } from './flags';
8
+ export * as VisitorAnalytics from './analytics';
9
+ export { analytics } from './analytics';
8
10
  export interface TempsClientConfig {
9
11
  baseUrl: string;
10
12
  apiKey?: string;
@@ -1576,6 +1578,48 @@ declare class Email {
1576
1578
  request: Request;
1577
1579
  response: Response;
1578
1580
  }>;
1581
+ listAuthorizedProjects: (options: Parameters<typeof sdk.listEmailDomainProjects>[0]) => Promise<{
1582
+ data: import(".").AuthorizedEmailDomainProjectResponse[];
1583
+ request: Request;
1584
+ response: Response;
1585
+ }> | Promise<({
1586
+ data: import(".").AuthorizedEmailDomainProjectResponse[];
1587
+ error: undefined;
1588
+ } | {
1589
+ data: undefined;
1590
+ error: unknown;
1591
+ }) & {
1592
+ request: Request;
1593
+ response: Response;
1594
+ }>;
1595
+ authorizeProject: (options: Parameters<typeof sdk.authorizeEmailDomainProject>[0]) => Promise<{
1596
+ data: void;
1597
+ request: Request;
1598
+ response: Response;
1599
+ }> | Promise<({
1600
+ data: void;
1601
+ error: undefined;
1602
+ } | {
1603
+ data: undefined;
1604
+ error: unknown;
1605
+ }) & {
1606
+ request: Request;
1607
+ response: Response;
1608
+ }>;
1609
+ revokeProject: (options: Parameters<typeof sdk.revokeEmailDomainProject>[0]) => Promise<{
1610
+ data: void;
1611
+ request: Request;
1612
+ response: Response;
1613
+ }> | Promise<({
1614
+ data: void;
1615
+ error: undefined;
1616
+ } | {
1617
+ data: undefined;
1618
+ error: unknown;
1619
+ }) & {
1620
+ request: Request;
1621
+ response: Response;
1622
+ }>;
1579
1623
  send: (options: Parameters<typeof sdk.sendEmail>[0]) => Promise<{
1580
1624
  data: import(".").SendEmailResponseBody;
1581
1625
  request: Request;
@@ -3178,6 +3222,48 @@ declare class Projects {
3178
3222
  request: Request;
3179
3223
  response: Response;
3180
3224
  }>;
3225
+ getServiceTemplate: (options: Parameters<typeof sdk.getProjectServiceTemplate>[0]) => Promise<{
3226
+ data: import(".").ServiceTemplateInstanceResponse;
3227
+ request: Request;
3228
+ response: Response;
3229
+ }> | Promise<({
3230
+ data: import(".").ServiceTemplateInstanceResponse;
3231
+ error: undefined;
3232
+ } | {
3233
+ data: undefined;
3234
+ error: unknown;
3235
+ }) & {
3236
+ request: Request;
3237
+ response: Response;
3238
+ }>;
3239
+ updateServiceRuntime: (options: Parameters<typeof sdk.updateServiceTemplateRuntime>[0]) => Promise<{
3240
+ data: import(".").ProjectResponse;
3241
+ request: Request;
3242
+ response: Response;
3243
+ }> | Promise<({
3244
+ data: import(".").ProjectResponse;
3245
+ error: undefined;
3246
+ } | {
3247
+ data: undefined;
3248
+ error: unknown;
3249
+ }) & {
3250
+ request: Request;
3251
+ response: Response;
3252
+ }>;
3253
+ upgradeServiceTemplate: (options: Parameters<typeof sdk.upgradeProjectServiceTemplate>[0]) => Promise<{
3254
+ data: import(".").ProjectResponse;
3255
+ request: Request;
3256
+ response: Response;
3257
+ }> | Promise<({
3258
+ data: import(".").ProjectResponse;
3259
+ error: undefined;
3260
+ } | {
3261
+ data: undefined;
3262
+ error: unknown;
3263
+ }) & {
3264
+ request: Request;
3265
+ response: Response;
3266
+ }>;
3181
3267
  getDeployments: (options: Parameters<typeof sdk.getProjectDeployments>[0]) => Promise<{
3182
3268
  data: import(".").DeploymentListResponse;
3183
3269
  request: Request;