@allisall/sdk 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +227 -2
- package/dist/client.d.ts +121 -0
- package/dist/client.js +193 -0
- package/dist/decimal.d.ts +20 -0
- package/dist/decimal.js +23 -0
- package/dist/errors.d.ts +79 -0
- package/dist/errors.js +98 -0
- package/dist/generated/openapi.d.ts +7724 -0
- package/dist/generated/openapi.js +4 -0
- package/dist/generated/operations.d.ts +37 -0
- package/dist/generated/operations.js +976 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +5 -0
- package/dist/ingest.d.ts +28 -0
- package/dist/ingest.js +247 -0
- package/dist/money.d.ts +57 -0
- package/dist/money.js +284 -0
- package/dist/multipart.d.ts +27 -0
- package/dist/multipart.js +48 -0
- package/dist/options.d.ts +50 -0
- package/dist/options.js +73 -0
- package/dist/pagination.d.ts +55 -0
- package/dist/pagination.js +85 -0
- package/dist/request.d.ts +117 -0
- package/dist/request.js +363 -0
- package/dist/resources/agents.d.ts +51 -0
- package/dist/resources/agents.js +65 -0
- package/dist/resources/analytics.d.ts +42 -0
- package/dist/resources/analytics.js +68 -0
- package/dist/resources/api-keys.d.ts +54 -0
- package/dist/resources/api-keys.js +63 -0
- package/dist/resources/calculations.d.ts +78 -0
- package/dist/resources/calculations.js +111 -0
- package/dist/resources/clients.d.ts +65 -0
- package/dist/resources/clients.js +85 -0
- package/dist/resources/cost.d.ts +69 -0
- package/dist/resources/cost.js +89 -0
- package/dist/resources/dashboard.d.ts +24 -0
- package/dist/resources/dashboard.js +28 -0
- package/dist/resources/events.d.ts +47 -0
- package/dist/resources/events.js +69 -0
- package/dist/resources/health.d.ts +14 -0
- package/dist/resources/health.js +17 -0
- package/dist/resources/imports.d.ts +33 -0
- package/dist/resources/imports.js +37 -0
- package/dist/resources/outcome-types.d.ts +25 -0
- package/dist/resources/outcome-types.js +33 -0
- package/dist/resources/reports.d.ts +77 -0
- package/dist/resources/reports.js +103 -0
- package/dist/resources/value-models.d.ts +92 -0
- package/dist/resources/value-models.js +126 -0
- package/dist/retry.d.ts +18 -0
- package/dist/retry.js +105 -0
- package/dist/runtime.d.ts +19 -0
- package/dist/runtime.js +61 -0
- package/dist/share.d.ts +52 -0
- package/dist/share.js +60 -0
- package/dist/transport.d.ts +102 -0
- package/dist/transport.js +269 -0
- package/dist/types.d.ts +268 -0
- package/dist/types.js +89 -0
- package/dist/unicode.d.ts +2 -0
- package/dist/unicode.js +11 -0
- package/dist/uuid.d.ts +6 -0
- package/dist/uuid.js +20 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +40 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
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"]>;
|
|
9
|
+
/** The known request-level error codes, in the API's catalogue order. */
|
|
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", "payload_too_large", "uri_too_long", "unsupported_media_type", "idempotency_key_reused", "rate_limited", "internal_error"];
|
|
11
|
+
/** The known field-level error codes, in the API's catalogue order. */
|
|
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"];
|
|
13
|
+
/** The event categories. */
|
|
14
|
+
export declare const EVENT_CATEGORIES: readonly ["session", "task", "model", "outcome", "exception"];
|
|
15
|
+
/** The members of `EventInput`, in the API's order. */
|
|
16
|
+
export declare const EVENT_INPUT_MEMBERS: readonly ["event_id", "timestamp", "agent_key", "client_key", "category", "event_type", "outcome_type", "quantity", "cost", "tokens_in", "tokens_out", "model", "currency", "metadata"];
|
|
17
|
+
/**
|
|
18
|
+
* A request-level error code. New codes are additive, so any other string
|
|
19
|
+
* is possible too: branch on the codes you handle, and fall back on the
|
|
20
|
+
* HTTP status for the rest.
|
|
21
|
+
*/
|
|
22
|
+
export type ErrorCode = (typeof ERROR_CODES)[number] | (string & {});
|
|
23
|
+
/**
|
|
24
|
+
* A field-level error code, as in a rejected ingest row. New codes are
|
|
25
|
+
* additive, so any other string is possible too.
|
|
26
|
+
*/
|
|
27
|
+
export type FieldErrorCode = (typeof FIELD_ERROR_CODES)[number] | (string & {});
|
|
28
|
+
/** An event category. */
|
|
29
|
+
export type EventCategory = (typeof EVENT_CATEGORIES)[number];
|
|
30
|
+
/**
|
|
31
|
+
* One event to ingest. Members keep the API's snake_case names. The SDK
|
|
32
|
+
* sends every member the object holds, so a misspelt member reaches the
|
|
33
|
+
* API and is reported as a rejected row rather than dropped.
|
|
34
|
+
*/
|
|
35
|
+
export interface EventInput {
|
|
36
|
+
/**
|
|
37
|
+
* A sender-chosen id; a repeat within the workspace is a duplicate. When
|
|
38
|
+
* it is absent, `null` or `""`, the SDK generates a UUID. Set your own
|
|
39
|
+
* when the same event may be sent again in a later call, such as after a
|
|
40
|
+
* queue redelivers a message.
|
|
41
|
+
*/
|
|
42
|
+
event_id?: string | null;
|
|
43
|
+
/** When the event happened: a `Date`, or an RFC 3339 instant with an offset. */
|
|
44
|
+
timestamp: Date | string;
|
|
45
|
+
/** The agent that acted. */
|
|
46
|
+
agent_key: string;
|
|
47
|
+
/** The client the event belongs to. */
|
|
48
|
+
client_key?: string | null;
|
|
49
|
+
/** The event's category. */
|
|
50
|
+
category: EventCategory;
|
|
51
|
+
/** What the agent did. */
|
|
52
|
+
event_type: string;
|
|
53
|
+
/** Required when `category` is `outcome`. */
|
|
54
|
+
outcome_type?: string | null;
|
|
55
|
+
/** Absent, `null` or `0` means 1. */
|
|
56
|
+
quantity?: number | null;
|
|
57
|
+
/** In `currency`, or the workspace currency: a `Decimal`, or a finite number. */
|
|
58
|
+
cost?: Decimal | number | null;
|
|
59
|
+
/** Tokens in. */
|
|
60
|
+
tokens_in?: number | null;
|
|
61
|
+
/** Tokens out. */
|
|
62
|
+
tokens_out?: number | null;
|
|
63
|
+
/** The model the agent invoked. */
|
|
64
|
+
model?: string | null;
|
|
65
|
+
/** The currency of `cost`. Absent means the workspace currency. */
|
|
66
|
+
currency?: string | null;
|
|
67
|
+
/** Free-form members, at most 8 KB serialised. */
|
|
68
|
+
metadata?: Record<string, unknown> | null;
|
|
69
|
+
}
|
|
70
|
+
/** One problem with a rejected ingest row. */
|
|
71
|
+
export interface IngestRowError {
|
|
72
|
+
/** The zero-based position of the row in the list passed to `ingest`. */
|
|
73
|
+
index: number;
|
|
74
|
+
/** The field-level code. */
|
|
75
|
+
code: FieldErrorCode;
|
|
76
|
+
/** An RFC 6901 JSON Pointer to the problem, starting `/events/<index>`. */
|
|
77
|
+
pointer: string;
|
|
78
|
+
/** Human text. Its wording may change at any time. */
|
|
79
|
+
detail: string;
|
|
80
|
+
}
|
|
81
|
+
/** The outcome of one ingest batch, as the API sends it. */
|
|
82
|
+
export interface IngestResult {
|
|
83
|
+
accepted: number;
|
|
84
|
+
duplicates: number;
|
|
85
|
+
rejected: number;
|
|
86
|
+
errors: IngestRowError[];
|
|
87
|
+
errors_truncated: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The combined outcome of one `ingest` call, over the whole list. */
|
|
90
|
+
export interface IngestSummary {
|
|
91
|
+
/** Events stored. */
|
|
92
|
+
accepted: number;
|
|
93
|
+
/** Events already stored, by `event_id` or content hash. */
|
|
94
|
+
duplicates: number;
|
|
95
|
+
/** Events refused, counted once each, including any too large to send. */
|
|
96
|
+
rejected: number;
|
|
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
|
+
*/
|
|
102
|
+
errors: IngestRowError[];
|
|
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
|
+
*/
|
|
108
|
+
errors_truncated: boolean;
|
|
109
|
+
/** The number of batches sent. */
|
|
110
|
+
batches: number;
|
|
111
|
+
}
|
|
112
|
+
/** One problem in a request, from a problem document's `errors`. */
|
|
113
|
+
export interface FieldError {
|
|
114
|
+
/** The field-level code. */
|
|
115
|
+
code: FieldErrorCode;
|
|
116
|
+
/** An RFC 6901 JSON Pointer into the request body. */
|
|
117
|
+
pointer?: string;
|
|
118
|
+
/** A query parameter, by name. */
|
|
119
|
+
parameter?: string;
|
|
120
|
+
/** A request header, by name. */
|
|
121
|
+
header?: string;
|
|
122
|
+
/** A multipart part, by its form field name. */
|
|
123
|
+
part?: string;
|
|
124
|
+
/** A column of a CSV part. */
|
|
125
|
+
column?: string;
|
|
126
|
+
/** Human text. Its wording may change at any time. */
|
|
127
|
+
detail: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* An RFC 9457 problem document, as the API sends it with an error status.
|
|
131
|
+
* The API sends every member but `errors`; each is optional here because a
|
|
132
|
+
* member of the wrong type, such as one from a proxy, is left out rather
|
|
133
|
+
* than failing the whole document.
|
|
134
|
+
*/
|
|
135
|
+
export interface Problem {
|
|
136
|
+
/** A URI identifying the problem; it maps one to one onto `code`. */
|
|
137
|
+
type?: string;
|
|
138
|
+
/** The fixed summary for `code`. */
|
|
139
|
+
title?: string;
|
|
140
|
+
/** The response status. */
|
|
141
|
+
status?: number;
|
|
142
|
+
/** Human text about this occurrence. Its wording may change at any time. */
|
|
143
|
+
detail?: string;
|
|
144
|
+
/** The error code. Branch on it. */
|
|
145
|
+
code?: ErrorCode;
|
|
146
|
+
/** The request's id, to quote when reporting the problem. */
|
|
147
|
+
request_id?: string;
|
|
148
|
+
/** Every problem found. Present only with `validation_failed`. */
|
|
149
|
+
errors?: FieldError[];
|
|
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 Scope = Schemas["Scope"];
|
|
158
|
+
export type CostTargetKind = Schemas["CostTargetKind"];
|
|
159
|
+
export type EventSource = Schemas["EventSource"];
|
|
160
|
+
export type UndefinedReason = Schemas["UndefinedReason"];
|
|
161
|
+
export type DisclosureKind = Schemas["DisclosureKind"];
|
|
162
|
+
export type PortfolioExclusionReason = Schemas["PortfolioExclusionReason"];
|
|
163
|
+
export type HealthDirection = Schemas["HealthDirection"];
|
|
164
|
+
export type HealthUnavailable = Schemas["HealthUnavailable"];
|
|
165
|
+
export type Client = Schemas["Client"];
|
|
166
|
+
export type AssignedAgent = Schemas["AssignedAgent"];
|
|
167
|
+
export type ClientDetail = Schemas["ClientDetail"];
|
|
168
|
+
export type ClientCreate = Schemas["ClientCreate"];
|
|
169
|
+
export type ClientPatch = Schemas["ClientPatch"];
|
|
170
|
+
export type ClientAgentsSet = Schemas["ClientAgentsSet"];
|
|
171
|
+
export type ClientAgents = Schemas["ClientAgents"];
|
|
172
|
+
export type Agent = Schemas["Agent"];
|
|
173
|
+
export type AgentListItem = Schemas["AgentListItem"];
|
|
174
|
+
export type AgentStats = Schemas["AgentStats"];
|
|
175
|
+
export type AgentDetail = Schemas["AgentDetail"];
|
|
176
|
+
export type AgentCreate = Schemas["AgentCreate"];
|
|
177
|
+
export type AgentPatch = Schemas["AgentPatch"];
|
|
178
|
+
export type ValueLineItem = Schemas["ValueLineItem"];
|
|
179
|
+
export type ValueModel = Schemas["ValueModel"];
|
|
180
|
+
export type ValueModelSummary = Schemas["ValueModelSummary"];
|
|
181
|
+
export type ValueModelCreate = Schemas["ValueModelCreate"];
|
|
182
|
+
export type ValueModelPatch = Schemas["ValueModelPatch"];
|
|
183
|
+
export type ValueLineItemInput = Schemas["ValueLineItemInput"];
|
|
184
|
+
export type ValueLineItemsSet = Schemas["ValueLineItemsSet"];
|
|
185
|
+
export type ValueTemplateLineItem = Schemas["ValueTemplateLineItem"];
|
|
186
|
+
export type ValueTemplate = Schemas["ValueTemplate"];
|
|
187
|
+
export type OutcomeTypeUsage = Schemas["OutcomeTypeUsage"];
|
|
188
|
+
export type CostTarget = Schemas["CostTarget"];
|
|
189
|
+
export type CostTargetInput = Schemas["CostTargetInput"];
|
|
190
|
+
export type CostLineItem = Schemas["CostLineItem"];
|
|
191
|
+
export type CostLineItemCreate = Schemas["CostLineItemCreate"];
|
|
192
|
+
export type CostLineItemPatch = Schemas["CostLineItemPatch"];
|
|
193
|
+
export type ModelRate = Schemas["ModelRate"];
|
|
194
|
+
export type PriceTable = Schemas["PriceTable"];
|
|
195
|
+
export type ModelRateInput = Schemas["ModelRateInput"];
|
|
196
|
+
export type PriceTableSet = Schemas["PriceTableSet"];
|
|
197
|
+
export type Ratios = Schemas["Ratios"];
|
|
198
|
+
export type ValueModelRef = Schemas["ValueModelRef"];
|
|
199
|
+
export type ValueLine = Schemas["ValueLine"];
|
|
200
|
+
export type ValueCoverage = Schemas["ValueCoverage"];
|
|
201
|
+
export type ValueResult = Schemas["ValueResult"];
|
|
202
|
+
export type ManualCostLine = Schemas["ManualCostLine"];
|
|
203
|
+
export type TokenCostLine = Schemas["TokenCostLine"];
|
|
204
|
+
export type AgentCostLine = Schemas["AgentCostLine"];
|
|
205
|
+
export type UnattributedLineItem = Schemas["UnattributedLineItem"];
|
|
206
|
+
export type CostCoverage = Schemas["CostCoverage"];
|
|
207
|
+
export type CostResult = Schemas["CostResult"];
|
|
208
|
+
export type ClientValue = Schemas["ClientValue"];
|
|
209
|
+
export type ClientCost = Schemas["ClientCost"];
|
|
210
|
+
export type RoiResult = Schemas["RoiResult"];
|
|
211
|
+
export type Anomalies = Schemas["Anomalies"];
|
|
212
|
+
export type AttributedEvent = Schemas["AttributedEvent"];
|
|
213
|
+
export type ClientEventList = Schemas["ClientEventList"];
|
|
214
|
+
export type Checklist = Schemas["Checklist"];
|
|
215
|
+
export type ChecklistInput = Schemas["ChecklistInput"];
|
|
216
|
+
export type CalculationSnapshot = Schemas["CalculationSnapshot"];
|
|
217
|
+
export type Calculation = Schemas["Calculation"];
|
|
218
|
+
export type CalculationSummary = Schemas["CalculationSummary"];
|
|
219
|
+
export type CalculationCreate = Schemas["CalculationCreate"];
|
|
220
|
+
export type Disclosure = Schemas["Disclosure"];
|
|
221
|
+
export type DisclosureEdit = Schemas["DisclosureEdit"];
|
|
222
|
+
export type Report = Schemas["Report"];
|
|
223
|
+
export type ReportSummary = Schemas["ReportSummary"];
|
|
224
|
+
export type ReportWithPreview = Schemas["ReportWithPreview"];
|
|
225
|
+
export type ReportPatch = Schemas["ReportPatch"];
|
|
226
|
+
export type PublicReport = Schemas["PublicReport"];
|
|
227
|
+
export type PortfolioClient = Schemas["PortfolioClient"];
|
|
228
|
+
export type Dashboard = Schemas["Dashboard"];
|
|
229
|
+
export type Renewal = Schemas["Renewal"];
|
|
230
|
+
export type ApiKey = Schemas["ApiKey"];
|
|
231
|
+
export type ApiKeyWithToken = Schemas["ApiKeyWithToken"];
|
|
232
|
+
export type ApiKeyCreate = Schemas["ApiKeyCreate"];
|
|
233
|
+
export type ImportMapping = Schemas["ImportMapping"];
|
|
234
|
+
export type ImportRowError = Schemas["ImportRowError"];
|
|
235
|
+
export type PreviewEvent = Schemas["PreviewEvent"];
|
|
236
|
+
export type PreviewRow = Schemas["PreviewRow"];
|
|
237
|
+
export type ImportPreview = Schemas["ImportPreview"];
|
|
238
|
+
export type ImportResult = Schemas["ImportResult"];
|
|
239
|
+
export type Health = Schemas["Health"];
|
|
240
|
+
export type ClientList = Schemas["ClientList"];
|
|
241
|
+
export type AgentList = Schemas["AgentList"];
|
|
242
|
+
export type ValueModelList = Schemas["ValueModelList"];
|
|
243
|
+
export type OutcomeTypeList = Schemas["OutcomeTypeList"];
|
|
244
|
+
export type ValueTemplateList = Schemas["ValueTemplateList"];
|
|
245
|
+
export type CostLineItemList = Schemas["CostLineItemList"];
|
|
246
|
+
export type CalculationList = Schemas["CalculationList"];
|
|
247
|
+
export type ReportList = Schemas["ReportList"];
|
|
248
|
+
export type RenewalList = Schemas["RenewalList"];
|
|
249
|
+
export type ApiKeyList = Schemas["ApiKeyList"];
|
|
250
|
+
export type ListClientsQuery = QueryOf<"listClients">;
|
|
251
|
+
export type ListClientOutcomeTypesQuery = QueryOf<"listClientOutcomeTypes">;
|
|
252
|
+
export type GetClientValueQuery = QueryOf<"getClientValue">;
|
|
253
|
+
export type GetClientCostQuery = QueryOf<"getClientCost">;
|
|
254
|
+
export type GetClientRoiQuery = QueryOf<"getClientRoi">;
|
|
255
|
+
export type ListClientEventsQuery = QueryOf<"listClientEvents">;
|
|
256
|
+
export type ListClientCalculationsQuery = QueryOf<"listClientCalculations">;
|
|
257
|
+
export type GetClientAnomaliesQuery = QueryOf<"getClientAnomalies">;
|
|
258
|
+
export type ListAgentsQuery = QueryOf<"listAgents">;
|
|
259
|
+
export type GetAgentQuery = QueryOf<"getAgent">;
|
|
260
|
+
export type ListValueModelsQuery = QueryOf<"listValueModels">;
|
|
261
|
+
export type ListOutcomeTypesQuery = QueryOf<"listOutcomeTypes">;
|
|
262
|
+
export type ListValueTemplatesQuery = QueryOf<"listValueTemplates">;
|
|
263
|
+
export type ListCostLineItemsQuery = QueryOf<"listCostLineItems">;
|
|
264
|
+
export type ListCalculationReportsQuery = QueryOf<"listCalculationReports">;
|
|
265
|
+
export type GetDashboardQuery = QueryOf<"getDashboard">;
|
|
266
|
+
export type ListRenewalsQuery = QueryOf<"listRenewals">;
|
|
267
|
+
export type ListApiKeysQuery = QueryOf<"listApiKeys">;
|
|
268
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
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.
|
|
13
|
+
/** The known request-level error codes, in the API's catalogue order. */
|
|
14
|
+
export const ERROR_CODES = [
|
|
15
|
+
"invalid_json",
|
|
16
|
+
"validation_failed",
|
|
17
|
+
"unauthenticated",
|
|
18
|
+
"insufficient_scope",
|
|
19
|
+
"session_required",
|
|
20
|
+
"account_not_provisioned",
|
|
21
|
+
"not_found",
|
|
22
|
+
"no_active_value_model",
|
|
23
|
+
"method_not_allowed",
|
|
24
|
+
"idempotency_key_in_use",
|
|
25
|
+
"client_key_in_use",
|
|
26
|
+
"agent_key_in_use",
|
|
27
|
+
"client_has_events",
|
|
28
|
+
"client_has_calculations",
|
|
29
|
+
"agent_has_events",
|
|
30
|
+
"client_key_has_events",
|
|
31
|
+
"value_model_exists",
|
|
32
|
+
"value_model_version_stale",
|
|
33
|
+
"calculation_transition_invalid",
|
|
34
|
+
"calculation_not_draft",
|
|
35
|
+
"calculation_not_published",
|
|
36
|
+
"report_shared",
|
|
37
|
+
"report_not_shared",
|
|
38
|
+
"api_key_revoked",
|
|
39
|
+
"payload_too_large",
|
|
40
|
+
"uri_too_long",
|
|
41
|
+
"unsupported_media_type",
|
|
42
|
+
"idempotency_key_reused",
|
|
43
|
+
"rate_limited",
|
|
44
|
+
"internal_error",
|
|
45
|
+
];
|
|
46
|
+
/** The known field-level error codes, in the API's catalogue order. */
|
|
47
|
+
export const FIELD_ERROR_CODES = [
|
|
48
|
+
"required",
|
|
49
|
+
"unknown_field",
|
|
50
|
+
"immutable",
|
|
51
|
+
"invalid_type",
|
|
52
|
+
"invalid_format",
|
|
53
|
+
"invalid_value",
|
|
54
|
+
"too_long",
|
|
55
|
+
"too_many",
|
|
56
|
+
"out_of_range",
|
|
57
|
+
"too_precise",
|
|
58
|
+
"duplicate",
|
|
59
|
+
"too_large",
|
|
60
|
+
"mutually_exclusive",
|
|
61
|
+
"unknown_reference",
|
|
62
|
+
"client_key_required",
|
|
63
|
+
"currency_mismatch",
|
|
64
|
+
];
|
|
65
|
+
/** The event categories. */
|
|
66
|
+
export const EVENT_CATEGORIES = [
|
|
67
|
+
"session",
|
|
68
|
+
"task",
|
|
69
|
+
"model",
|
|
70
|
+
"outcome",
|
|
71
|
+
"exception",
|
|
72
|
+
];
|
|
73
|
+
/** The members of `EventInput`, in the API's order. */
|
|
74
|
+
export const EVENT_INPUT_MEMBERS = [
|
|
75
|
+
"event_id",
|
|
76
|
+
"timestamp",
|
|
77
|
+
"agent_key",
|
|
78
|
+
"client_key",
|
|
79
|
+
"category",
|
|
80
|
+
"event_type",
|
|
81
|
+
"outcome_type",
|
|
82
|
+
"quantity",
|
|
83
|
+
"cost",
|
|
84
|
+
"tokens_in",
|
|
85
|
+
"tokens_out",
|
|
86
|
+
"model",
|
|
87
|
+
"currency",
|
|
88
|
+
"metadata",
|
|
89
|
+
];
|
package/dist/unicode.js
ADDED
|
@@ -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/uuid.d.ts
ADDED
package/dist/uuid.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const HEX = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
2
|
+
/**
|
|
3
|
+
* Returns a new UUID version 4 (RFC 9562 §5.4), lowercase, in the
|
|
4
|
+
* 8-4-4-4-12 form. It uses `crypto.getRandomValues`, which, unlike
|
|
5
|
+
* `crypto.randomUUID`, every browser offers outside secure contexts too.
|
|
6
|
+
*/
|
|
7
|
+
export function uuidv4() {
|
|
8
|
+
const bytes = new Uint8Array(16);
|
|
9
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
10
|
+
// Version 4 in the high nibble of byte 6; variant 10 in the top bits of byte 8.
|
|
11
|
+
bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x40;
|
|
12
|
+
bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
|
|
13
|
+
let out = "";
|
|
14
|
+
for (let i = 0; i < 16; i++) {
|
|
15
|
+
if (i === 4 || i === 6 || i === 8 || i === 10)
|
|
16
|
+
out += "-";
|
|
17
|
+
out += HEX[bytes[i] ?? 0];
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allisall/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "The allisall SDK for TypeScript and JavaScript: a typed client for the allisall API, from sending events to publishing reports.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/All-is-AI/allisall-typescript.git"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"NOTICE"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.build.json",
|
|
29
|
+
"lint": "biome check . && tsc --noEmit -p tsconfig.json",
|
|
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 && tsc -p test/consumer/tsconfig.examples.json"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@biomejs/biome": "2.5.4",
|
|
35
|
+
"@types/node": "^22.20.5",
|
|
36
|
+
"openapi-typescript": "7.13.0",
|
|
37
|
+
"typescript": "~5.9.3",
|
|
38
|
+
"typescript-5.0": "npm:typescript@5.0.4",
|
|
39
|
+
"vitest": "^4.1.10",
|
|
40
|
+
"yaml": "2.9.0"
|
|
41
|
+
}
|
|
42
|
+
}
|