@allisall/sdk 0.1.0 → 0.4.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.
Files changed (66) hide show
  1. package/README.md +145 -4
  2. package/dist/client.d.ts +87 -37
  3. package/dist/client.js +144 -73
  4. package/dist/generated/openapi.d.ts +9497 -0
  5. package/dist/generated/openapi.js +4 -0
  6. package/dist/generated/operations.d.ts +42 -0
  7. package/dist/generated/operations.js +1167 -0
  8. package/dist/import-mapping.d.ts +10 -0
  9. package/dist/import-mapping.js +20 -0
  10. package/dist/index.d.ts +8 -2
  11. package/dist/index.js +2 -0
  12. package/dist/ingest.d.ts +1 -1
  13. package/dist/ingest.js +2 -2
  14. package/dist/money.d.ts +57 -0
  15. package/dist/money.js +284 -0
  16. package/dist/multipart.d.ts +29 -0
  17. package/dist/multipart.js +48 -0
  18. package/dist/options.d.ts +50 -0
  19. package/dist/options.js +73 -0
  20. package/dist/pagination.d.ts +55 -0
  21. package/dist/pagination.js +85 -0
  22. package/dist/request.d.ts +126 -0
  23. package/dist/request.js +403 -0
  24. package/dist/resources/agents.d.ts +58 -0
  25. package/dist/resources/agents.js +72 -0
  26. package/dist/resources/analytics.d.ts +42 -0
  27. package/dist/resources/analytics.js +68 -0
  28. package/dist/resources/api-keys.d.ts +54 -0
  29. package/dist/resources/api-keys.js +63 -0
  30. package/dist/resources/calculations.d.ts +98 -0
  31. package/dist/resources/calculations.js +133 -0
  32. package/dist/resources/clients.d.ts +93 -0
  33. package/dist/resources/clients.js +113 -0
  34. package/dist/resources/cost.d.ts +76 -0
  35. package/dist/resources/cost.js +96 -0
  36. package/dist/resources/dashboard.d.ts +32 -0
  37. package/dist/resources/dashboard.js +36 -0
  38. package/dist/resources/events.d.ts +116 -0
  39. package/dist/resources/events.js +145 -0
  40. package/dist/resources/health.d.ts +14 -0
  41. package/dist/resources/health.js +17 -0
  42. package/dist/resources/imports.d.ts +56 -0
  43. package/dist/resources/imports.js +63 -0
  44. package/dist/resources/onboarding.d.ts +29 -0
  45. package/dist/resources/onboarding.js +34 -0
  46. package/dist/resources/outcome-types.d.ts +25 -0
  47. package/dist/resources/outcome-types.js +33 -0
  48. package/dist/resources/reports.d.ts +92 -0
  49. package/dist/resources/reports.js +120 -0
  50. package/dist/resources/value-models.d.ts +99 -0
  51. package/dist/resources/value-models.js +133 -0
  52. package/dist/resources/workspace.d.ts +15 -0
  53. package/dist/resources/workspace.js +18 -0
  54. package/dist/runtime.d.ts +2 -0
  55. package/dist/runtime.js +2 -1
  56. package/dist/share.d.ts +52 -0
  57. package/dist/share.js +60 -0
  58. package/dist/transport.d.ts +54 -5
  59. package/dist/transport.js +81 -32
  60. package/dist/types.d.ts +163 -3
  61. package/dist/types.js +18 -3
  62. package/dist/unicode.d.ts +2 -0
  63. package/dist/unicode.js +11 -0
  64. package/dist/version.d.ts +1 -1
  65. package/dist/version.js +1 -1
  66. package/package.json +4 -3
package/dist/types.d.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  import type { Decimal } from "./decimal.js";
2
+ import type { components, operations } from "./generated/openapi.js";
3
+ type Schemas = components["schemas"];
4
+ /**
5
+ * The query of one operation, from the generated types. The resource
6
+ * methods' arguments and the public `…Query` names below both use it.
7
+ */
8
+ export type QueryOf<K extends keyof operations> = NonNullable<operations[K]["parameters"]["query"]>;
2
9
  /** The known request-level error codes, in the API's catalogue order. */
3
- export declare const ERROR_CODES: readonly ["invalid_json", "validation_failed", "unauthenticated", "insufficient_scope", "session_required", "account_not_provisioned", "not_found", "no_active_value_model", "method_not_allowed", "idempotency_key_in_use", "client_key_in_use", "agent_key_in_use", "client_has_events", "client_has_calculations", "agent_has_events", "client_key_has_events", "value_model_exists", "value_model_version_stale", "calculation_transition_invalid", "calculation_not_draft", "calculation_not_published", "report_shared", "report_not_shared", "api_key_revoked", "payload_too_large", "uri_too_long", "unsupported_media_type", "idempotency_key_reused", "rate_limited", "internal_error"];
10
+ export declare const ERROR_CODES: readonly ["invalid_json", "validation_failed", "unauthenticated", "insufficient_scope", "session_required", "account_not_provisioned", "not_found", "no_active_value_model", "method_not_allowed", "idempotency_key_in_use", "client_key_in_use", "agent_key_in_use", "client_has_events", "client_has_calculations", "agent_has_events", "client_key_has_events", "value_model_exists", "value_model_version_stale", "calculation_transition_invalid", "calculation_not_draft", "calculation_not_published", "report_shared", "report_not_shared", "api_key_revoked", "invite_expired", "invite_used", "invite_revoked", "invite_email_mismatch", "email_has_workspace", "payload_too_large", "uri_too_long", "unsupported_media_type", "idempotency_key_reused", "rate_limited", "internal_error", "upstream_failed"];
4
11
  /** The known field-level error codes, in the API's catalogue order. */
5
12
  export declare const FIELD_ERROR_CODES: readonly ["required", "unknown_field", "immutable", "invalid_type", "invalid_format", "invalid_value", "too_long", "too_many", "out_of_range", "too_precise", "duplicate", "too_large", "mutually_exclusive", "unknown_reference", "client_key_required", "currency_mismatch"];
6
13
  /** The event categories. */
@@ -87,9 +94,17 @@ export interface IngestSummary {
87
94
  duplicates: number;
88
95
  /** Events refused, counted once each, including any too large to send. */
89
96
  rejected: number;
90
- /** One entry per problem, in the order of the list passed to `ingest`. */
97
+ /**
98
+ * One entry per problem, in the order of the list passed to `ingest`.
99
+ * When `errors_truncated` is `true`, some problems have no entry, and a
100
+ * rejected event may have none.
101
+ */
91
102
  errors: IngestRowError[];
92
- /** Whether any rejected row had more problems than `errors` holds. */
103
+ /**
104
+ * Whether `errors` omits any problem. The API lists at most 20 problems
105
+ * of one event, and at most 1,000,000 bytes of entries for one batch. The
106
+ * counts always cover every event.
107
+ */
93
108
  errors_truncated: boolean;
94
109
  /** The number of batches sent. */
95
110
  batches: number;
@@ -133,3 +148,148 @@ export interface Problem {
133
148
  /** Every problem found. Present only with `validation_failed`. */
134
149
  errors?: FieldError[];
135
150
  }
151
+ export type Period = Schemas["Period"];
152
+ export type PeriodInput = Schemas["PeriodInput"];
153
+ export type ClientStatus = Schemas["ClientStatus"];
154
+ export type AgentStatus = Schemas["AgentStatus"];
155
+ export type ValueModelStatus = Schemas["ValueModelStatus"];
156
+ export type CalculationState = Schemas["CalculationState"];
157
+ export type ReportState = Schemas["ReportState"];
158
+ export type RenewalTerm = Schemas["RenewalTerm"];
159
+ export type RenewalTermFilter = Schemas["RenewalTermFilter"];
160
+ export type RenewalWindow = Schemas["RenewalWindow"];
161
+ export type Scope = Schemas["Scope"];
162
+ export type CostTargetKind = Schemas["CostTargetKind"];
163
+ export type EventSource = Schemas["EventSource"];
164
+ export type UndefinedReason = Schemas["UndefinedReason"];
165
+ export type DisclosureKind = Schemas["DisclosureKind"];
166
+ export type PortfolioExclusionReason = Schemas["PortfolioExclusionReason"];
167
+ export type HealthDirection = Schemas["HealthDirection"];
168
+ export type HealthUnavailable = Schemas["HealthUnavailable"];
169
+ export type Client = Schemas["Client"];
170
+ export type AssignedAgent = Schemas["AssignedAgent"];
171
+ export type ClientDetail = Schemas["ClientDetail"];
172
+ export type ClientCreate = Schemas["ClientCreate"];
173
+ export type ClientPatch = Schemas["ClientPatch"];
174
+ export type ClientAgentsSet = Schemas["ClientAgentsSet"];
175
+ export type ClientAgents = Schemas["ClientAgents"];
176
+ export type Agent = Schemas["Agent"];
177
+ export type AgentListItem = Schemas["AgentListItem"];
178
+ export type AgentStats = Schemas["AgentStats"];
179
+ export type AgentDetail = Schemas["AgentDetail"];
180
+ export type AgentCreate = Schemas["AgentCreate"];
181
+ export type AgentPatch = Schemas["AgentPatch"];
182
+ export type ValueLineItem = Schemas["ValueLineItem"];
183
+ export type ValueModel = Schemas["ValueModel"];
184
+ export type ValueModelSummary = Schemas["ValueModelSummary"];
185
+ export type ValueModelCreate = Schemas["ValueModelCreate"];
186
+ export type ValueModelPatch = Schemas["ValueModelPatch"];
187
+ export type ValueLineItemInput = Schemas["ValueLineItemInput"];
188
+ export type ValueLineItemsSet = Schemas["ValueLineItemsSet"];
189
+ export type ValueTemplateLineItem = Schemas["ValueTemplateLineItem"];
190
+ export type ValueTemplate = Schemas["ValueTemplate"];
191
+ export type OutcomeTypeUsage = Schemas["OutcomeTypeUsage"];
192
+ export type CostTarget = Schemas["CostTarget"];
193
+ export type CostTargetInput = Schemas["CostTargetInput"];
194
+ export type CostLineItem = Schemas["CostLineItem"];
195
+ export type CostLineItemCreate = Schemas["CostLineItemCreate"];
196
+ export type CostLineItemPatch = Schemas["CostLineItemPatch"];
197
+ export type ModelRate = Schemas["ModelRate"];
198
+ export type PriceTable = Schemas["PriceTable"];
199
+ export type ModelRateInput = Schemas["ModelRateInput"];
200
+ export type PriceTableSet = Schemas["PriceTableSet"];
201
+ export type Ratios = Schemas["Ratios"];
202
+ export type ValueModelRef = Schemas["ValueModelRef"];
203
+ export type ValueLine = Schemas["ValueLine"];
204
+ export type ValueCoverage = Schemas["ValueCoverage"];
205
+ export type ValueResult = Schemas["ValueResult"];
206
+ export type ManualCostLine = Schemas["ManualCostLine"];
207
+ export type TokenCostLine = Schemas["TokenCostLine"];
208
+ export type AgentCostLine = Schemas["AgentCostLine"];
209
+ export type UnattributedLineItem = Schemas["UnattributedLineItem"];
210
+ export type CostCoverage = Schemas["CostCoverage"];
211
+ export type CostResult = Schemas["CostResult"];
212
+ export type ClientValue = Schemas["ClientValue"];
213
+ export type ClientCost = Schemas["ClientCost"];
214
+ export type RoiResult = Schemas["RoiResult"];
215
+ export type Anomalies = Schemas["Anomalies"];
216
+ export type AttributedEvent = Schemas["AttributedEvent"];
217
+ export type ClientEventList = Schemas["ClientEventList"];
218
+ export type EventList = Schemas["EventList"];
219
+ export type EventSummary = Schemas["EventSummary"];
220
+ export type EventDayCount = Schemas["EventDayCount"];
221
+ export type EventCategoryCount = Schemas["EventCategoryCount"];
222
+ export type EventArrivalList = Schemas["EventArrivalList"];
223
+ export type Checklist = Schemas["Checklist"];
224
+ export type ChecklistInput = Schemas["ChecklistInput"];
225
+ export type CalculationSnapshot = Schemas["CalculationSnapshot"];
226
+ export type Calculation = Schemas["Calculation"];
227
+ export type CalculationSummary = Schemas["CalculationSummary"];
228
+ export type CalculationCreate = Schemas["CalculationCreate"];
229
+ export type Disclosure = Schemas["Disclosure"];
230
+ export type DisclosureEdit = Schemas["DisclosureEdit"];
231
+ export type Report = Schemas["Report"];
232
+ export type ReportSummary = Schemas["ReportSummary"];
233
+ export type ReportWithPreview = Schemas["ReportWithPreview"];
234
+ export type ReportPatch = Schemas["ReportPatch"];
235
+ export type PublicReport = Schemas["PublicReport"];
236
+ export type PortfolioClient = Schemas["PortfolioClient"];
237
+ export type Dashboard = Schemas["Dashboard"];
238
+ export type Renewal = Schemas["Renewal"];
239
+ export type ApiKey = Schemas["ApiKey"];
240
+ export type ApiKeyWithToken = Schemas["ApiKeyWithToken"];
241
+ export type ApiKeyCreate = Schemas["ApiKeyCreate"];
242
+ export type ImportMapping = Schemas["ImportMapping"];
243
+ export type ImportRowError = Schemas["ImportRowError"];
244
+ export type PreviewEvent = Schemas["PreviewEvent"];
245
+ export type PreviewRow = Schemas["PreviewRow"];
246
+ export type ImportPreview = Schemas["ImportPreview"];
247
+ export type ImportResult = Schemas["ImportResult"];
248
+ export type ImportSummary = Schemas["ImportSummary"];
249
+ export type Import = Schemas["Import"];
250
+ export type AppliedImportMapping = Schemas["AppliedImportMapping"];
251
+ export type ImportDelimiter = Schemas["ImportDelimiter"];
252
+ export type Health = Schemas["Health"];
253
+ export type ImportList = Schemas["ImportList"];
254
+ export type ClientList = Schemas["ClientList"];
255
+ export type AgentList = Schemas["AgentList"];
256
+ export type ValueModelList = Schemas["ValueModelList"];
257
+ export type OutcomeTypeList = Schemas["OutcomeTypeList"];
258
+ export type ValueTemplateList = Schemas["ValueTemplateList"];
259
+ export type CostLineItemList = Schemas["CostLineItemList"];
260
+ export type CalculationList = Schemas["CalculationList"];
261
+ export type ReportList = Schemas["ReportList"];
262
+ export type WorkspaceCalculationList = Schemas["WorkspaceCalculationList"];
263
+ export type WorkspaceReportList = Schemas["WorkspaceReportList"];
264
+ export type RenewalList = Schemas["RenewalList"];
265
+ export type ApiKeyList = Schemas["ApiKeyList"];
266
+ export type Workspace = Schemas["Workspace"];
267
+ export type OnboardingStep = Schemas["OnboardingStep"];
268
+ export type OnboardingStepProgress = Schemas["OnboardingStepProgress"];
269
+ export type Onboarding = Schemas["Onboarding"];
270
+ export type OnboardingSkippedStepsSet = Schemas["OnboardingSkippedStepsSet"];
271
+ export type ListEventsQuery = QueryOf<"listEvents">;
272
+ export type GetEventSummaryQuery = QueryOf<"getEventSummary">;
273
+ export type ListEventArrivalsQuery = QueryOf<"listEventArrivals">;
274
+ export type ListImportsQuery = QueryOf<"listImports">;
275
+ export type ListClientsQuery = QueryOf<"listClients">;
276
+ export type ListClientOutcomeTypesQuery = QueryOf<"listClientOutcomeTypes">;
277
+ export type GetClientValueQuery = QueryOf<"getClientValue">;
278
+ export type GetClientCostQuery = QueryOf<"getClientCost">;
279
+ export type GetClientRoiQuery = QueryOf<"getClientRoi">;
280
+ export type ListClientEventsQuery = QueryOf<"listClientEvents">;
281
+ export type ListClientCalculationsQuery = QueryOf<"listClientCalculations">;
282
+ export type GetClientAnomaliesQuery = QueryOf<"getClientAnomalies">;
283
+ export type ListAgentsQuery = QueryOf<"listAgents">;
284
+ export type GetAgentQuery = QueryOf<"getAgent">;
285
+ export type ListValueModelsQuery = QueryOf<"listValueModels">;
286
+ export type ListOutcomeTypesQuery = QueryOf<"listOutcomeTypes">;
287
+ export type ListValueTemplatesQuery = QueryOf<"listValueTemplates">;
288
+ export type ListCostLineItemsQuery = QueryOf<"listCostLineItems">;
289
+ export type ListCalculationsQuery = QueryOf<"listCalculations">;
290
+ export type ListCalculationReportsQuery = QueryOf<"listCalculationReports">;
291
+ export type ListReportsQuery = QueryOf<"listReports">;
292
+ export type GetDashboardQuery = QueryOf<"getDashboard">;
293
+ export type ListRenewalsQuery = QueryOf<"listRenewals">;
294
+ export type ListApiKeysQuery = QueryOf<"listApiKeys">;
295
+ export {};
package/dist/types.js CHANGED
@@ -1,6 +1,15 @@
1
- // The wire types the SDK uses, written by hand from the API's OpenAPI
2
- // document. A test reads that document and holds every list below to it,
3
- // until types generated from the document replace this file.
1
+ // The public names of the wire types.
2
+ //
3
+ // Most are aliases of the types generated from the API's OpenAPI document,
4
+ // one per schema, under the schema's own name. The scalar schemas, such as
5
+ // `Money` and `Instant`, are not exported: each is a `string`, a `number` or
6
+ // a `Decimal`, and an exported `Date` would shadow the global one.
7
+ //
8
+ // The names this SDK exported before the generated types existed keep their
9
+ // hand-written definitions below: `ErrorCode`, `FieldErrorCode`,
10
+ // `EventCategory`, `EventInput`, `FieldError`, `Problem` and
11
+ // `IngestRowError`. A test holds each to the generated type it corresponds
12
+ // to, and reads the document to hold every list below to it.
4
13
  /** The known request-level error codes, in the API's catalogue order. */
5
14
  export const ERROR_CODES = [
6
15
  "invalid_json",
@@ -27,12 +36,18 @@ export const ERROR_CODES = [
27
36
  "report_shared",
28
37
  "report_not_shared",
29
38
  "api_key_revoked",
39
+ "invite_expired",
40
+ "invite_used",
41
+ "invite_revoked",
42
+ "invite_email_mismatch",
43
+ "email_has_workspace",
30
44
  "payload_too_large",
31
45
  "uri_too_long",
32
46
  "unsupported_media_type",
33
47
  "idempotency_key_reused",
34
48
  "rate_limited",
35
49
  "internal_error",
50
+ "upstream_failed",
36
51
  ];
37
52
  /** The known field-level error codes, in the API's catalogue order. */
38
53
  export const FIELD_ERROR_CODES = [
@@ -0,0 +1,2 @@
1
+ /** Whether `text` holds a UTF-16 surrogate without its partner. */
2
+ export declare function hasLoneSurrogate(text: string): boolean;
@@ -0,0 +1,11 @@
1
+ // Text that UTF-8 cannot encode. A JavaScript string is UTF-16, so it can
2
+ // hold a surrogate without its partner. JSON.stringify writes one as an
3
+ // escape such as \ud800, and a URL or form writes it as U+FFFD; either way
4
+ // the API stores a character the caller never sent.
5
+ // A high surrogate not followed by a low one, or a low one not preceded by
6
+ // a high one.
7
+ const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
8
+ /** Whether `text` holds a UTF-16 surrogate without its partner. */
9
+ export function hasLoneSurrogate(text) {
10
+ return LONE_SURROGATE.test(text);
11
+ }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The SDK's version. The release tooling updates it; never edit it by hand. */
2
- export declare const VERSION = "0.1.0";
2
+ export declare const VERSION = "0.4.0";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /** The SDK's version. The release tooling updates it; never edit it by hand. */
2
- export const VERSION = "0.1.0"; // x-release-please-version
2
+ export const VERSION = "0.4.0"; // x-release-please-version
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@allisall/sdk",
3
- "version": "0.1.0",
4
- "description": "The allisall SDK for TypeScript and JavaScript: send events to the allisall API.",
3
+ "version": "0.4.0",
4
+ "description": "The allisall SDK for TypeScript and JavaScript: a typed client for the allisall API, from sending events to publishing reports.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,11 +28,12 @@
28
28
  "build": "tsc -p tsconfig.build.json",
29
29
  "lint": "biome check . && tsc --noEmit -p tsconfig.json",
30
30
  "test": "vitest run && npm run test:consumer",
31
- "test:consumer": "tsc -p tsconfig.build.json && node test/consumer/extract-readme.mjs && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.bundler.json && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.node16.json && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.node-types.json"
31
+ "test:consumer": "tsc -p tsconfig.build.json && node test/consumer/extract-readme.mjs && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.bundler.json && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.node16.json && node node_modules/typescript-5.0/bin/tsc -p test/consumer/tsconfig.node-types.json && tsc -p test/consumer/tsconfig.examples.json"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@biomejs/biome": "2.5.4",
35
35
  "@types/node": "^22.20.5",
36
+ "openapi-typescript": "7.13.0",
36
37
  "typescript": "~5.9.3",
37
38
  "typescript-5.0": "npm:typescript@5.0.4",
38
39
  "vitest": "^4.1.10",