@rippling/rippling-sdk 0.2.0-alpha.108 → 0.2.0-alpha.109
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/client.d.mts +3 -0
- package/client.d.mts.map +1 -1
- package/client.d.ts +3 -0
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/lib/charts/builders.d.mts +18 -19
- package/lib/charts/builders.d.mts.map +1 -1
- package/lib/charts/builders.d.ts +18 -19
- package/lib/charts/builders.d.ts.map +1 -1
- package/lib/charts/builders.js +35 -28
- package/lib/charts/builders.js.map +1 -1
- package/lib/charts/builders.mjs +35 -28
- package/lib/charts/builders.mjs.map +1 -1
- package/lib/charts/describe.d.mts +6 -7
- package/lib/charts/describe.d.mts.map +1 -1
- package/lib/charts/describe.d.ts +6 -7
- package/lib/charts/describe.d.ts.map +1 -1
- package/lib/charts/describe.js +26 -27
- package/lib/charts/describe.js.map +1 -1
- package/lib/charts/describe.mjs +27 -28
- package/lib/charts/describe.mjs.map +1 -1
- package/lib/charts/errors.d.mts +2 -6
- package/lib/charts/errors.d.mts.map +1 -1
- package/lib/charts/errors.d.ts +2 -6
- package/lib/charts/errors.d.ts.map +1 -1
- package/lib/charts/errors.js +2 -6
- package/lib/charts/errors.js.map +1 -1
- package/lib/charts/errors.mjs +2 -6
- package/lib/charts/errors.mjs.map +1 -1
- package/lib/charts/evaluate.d.mts +5 -7
- package/lib/charts/evaluate.d.mts.map +1 -1
- package/lib/charts/evaluate.d.ts +5 -7
- package/lib/charts/evaluate.d.ts.map +1 -1
- package/lib/charts/evaluate.js +21 -35
- package/lib/charts/evaluate.js.map +1 -1
- package/lib/charts/evaluate.mjs +22 -36
- package/lib/charts/evaluate.mjs.map +1 -1
- package/lib/charts/schema.d.mts +8 -97
- package/lib/charts/schema.d.mts.map +1 -1
- package/lib/charts/schema.d.ts +8 -97
- package/lib/charts/schema.d.ts.map +1 -1
- package/lib/charts/schema.js +186 -65
- package/lib/charts/schema.js.map +1 -1
- package/lib/charts/schema.mjs +185 -65
- package/lib/charts/schema.mjs.map +1 -1
- package/lib/charts/types.d.mts +40 -25
- package/lib/charts/types.d.mts.map +1 -1
- package/lib/charts/types.d.ts +40 -25
- package/lib/charts/types.d.ts.map +1 -1
- package/lib/charts/types.js +8 -10
- package/lib/charts/types.js.map +1 -1
- package/lib/charts/types.mjs +8 -10
- package/lib/charts/types.mjs.map +1 -1
- package/lib/charts/visualization-grammar.d.mts +66 -0
- package/lib/charts/visualization-grammar.d.mts.map +1 -0
- package/lib/charts/visualization-grammar.d.ts +66 -0
- package/lib/charts/visualization-grammar.d.ts.map +1 -0
- package/lib/charts/visualization-grammar.js +70 -0
- package/lib/charts/visualization-grammar.js.map +1 -0
- package/lib/charts/visualization-grammar.mjs +67 -0
- package/lib/charts/visualization-grammar.mjs.map +1 -0
- package/lib/charts/vocabulary.d.mts +7 -0
- package/lib/charts/vocabulary.d.mts.map +1 -0
- package/lib/charts/vocabulary.d.ts +7 -0
- package/lib/charts/vocabulary.d.ts.map +1 -0
- package/lib/charts/vocabulary.js +10 -0
- package/lib/charts/vocabulary.js.map +1 -0
- package/lib/charts/vocabulary.mjs +7 -0
- package/lib/charts/vocabulary.mjs.map +1 -0
- package/lib/charts.d.mts +3 -3
- package/lib/charts.d.mts.map +1 -1
- package/lib/charts.d.ts +3 -3
- package/lib/charts.d.ts.map +1 -1
- package/lib/charts.js +2 -1
- package/lib/charts.js.map +1 -1
- package/lib/charts.mjs +1 -1
- package/lib/charts.mjs.map +1 -1
- package/package.json +4 -2
- package/resources/index.d.mts +1 -0
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -0
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/reimbursements.d.mts +1 -1
- package/resources/reimbursements.d.ts +1 -1
- package/resources/reimbursements.js +1 -1
- package/resources/reimbursements.mjs +1 -1
- package/resources/spend-categories.d.mts +140 -0
- package/resources/spend-categories.d.mts.map +1 -0
- package/resources/spend-categories.d.ts +140 -0
- package/resources/spend-categories.d.ts.map +1 -0
- package/resources/spend-categories.js +83 -0
- package/resources/spend-categories.js.map +1 -0
- package/resources/spend-categories.mjs +79 -0
- package/resources/spend-categories.mjs.map +1 -0
- package/src/client.ts +17 -0
- package/src/lib/charts/README.md +35 -28
- package/src/lib/charts/agent-reference.md +73 -0
- package/src/lib/charts/builders.ts +51 -35
- package/src/lib/charts/capabilities.json +96 -0
- package/src/lib/charts/describe.ts +31 -29
- package/src/lib/charts/errors.ts +2 -6
- package/src/lib/charts/evaluate.ts +25 -38
- package/src/lib/charts/schema.ts +232 -66
- package/src/lib/charts/types.ts +42 -31
- package/src/lib/charts/visualization-grammar.ts +67 -0
- package/src/lib/charts/vocabulary.ts +7 -0
- package/src/lib/charts.ts +8 -1
- package/src/resources/index.ts +7 -0
- package/src/resources/reimbursements.ts +1 -1
- package/src/resources/spend-categories.ts +175 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/lib/charts/guards.d.mts +0 -15
- package/lib/charts/guards.d.mts.map +0 -1
- package/lib/charts/guards.d.ts +0 -15
- package/lib/charts/guards.d.ts.map +0 -1
- package/lib/charts/guards.js +0 -38
- package/lib/charts/guards.js.map +0 -1
- package/lib/charts/guards.mjs +0 -34
- package/lib/charts/guards.mjs.map +0 -1
- package/src/lib/charts/guards.ts +0 -42
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../core/resource';
|
|
4
|
+
import * as BusinessPartnersAPI from './business-partners';
|
|
5
|
+
import { APIPromise } from '../core/api-promise';
|
|
6
|
+
import { PageCursorURL, PagePromise } from '../core/pagination';
|
|
7
|
+
import { RequestOptions } from '../internal/request-options';
|
|
8
|
+
import { path } from '../internal/utils/path';
|
|
9
|
+
|
|
10
|
+
export class SpendCategories extends APIResource {
|
|
11
|
+
/**
|
|
12
|
+
* A list of spend categories.
|
|
13
|
+
*
|
|
14
|
+
* - Requires: `Internal Testing`
|
|
15
|
+
* - Filterable fields: `name`
|
|
16
|
+
* - Sortable fields: `id`, `created_at`, `updated_at`
|
|
17
|
+
*
|
|
18
|
+
* @example HTTP
|
|
19
|
+
* Representative request and response shapes.
|
|
20
|
+
* ```
|
|
21
|
+
* GET /spend-categories/?filter=filter&order_by=order_by&limit=50&cursor=cursor HTTP/1.1
|
|
22
|
+
* Host: rest.ripplingapis.com
|
|
23
|
+
* Accept: application/json
|
|
24
|
+
* Rippling-Api-Version: 2024-08-01
|
|
25
|
+
*
|
|
26
|
+
* HTTP/1.1 200 OK
|
|
27
|
+
* Content-Type: application/json
|
|
28
|
+
*
|
|
29
|
+
* {
|
|
30
|
+
* "__meta": {
|
|
31
|
+
* "redacted_fields": [
|
|
32
|
+
* {
|
|
33
|
+
* "name": "date_of_birth",
|
|
34
|
+
* "reason": "Insufficient entitlements"
|
|
35
|
+
* }
|
|
36
|
+
* ]
|
|
37
|
+
* },
|
|
38
|
+
* "results": [
|
|
39
|
+
* {
|
|
40
|
+
* "id": "string",
|
|
41
|
+
* "created_at": "string",
|
|
42
|
+
* "updated_at": "string",
|
|
43
|
+
* "name": "string",
|
|
44
|
+
* "active": false
|
|
45
|
+
* }
|
|
46
|
+
* ],
|
|
47
|
+
* "next_link": "string"
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
list(
|
|
52
|
+
query: SpendCategoryListParams | null | undefined = {},
|
|
53
|
+
options?: RequestOptions,
|
|
54
|
+
): PagePromise<SpendCategoryListResponsesPageCursorURL, SpendCategoryListResponse> {
|
|
55
|
+
return this._client.getAPIList('/spend-categories/', PageCursorURL<SpendCategoryListResponse>, {
|
|
56
|
+
query,
|
|
57
|
+
...options,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Retrieve a specific spend category
|
|
63
|
+
*
|
|
64
|
+
* @example HTTP
|
|
65
|
+
* Representative request and response shapes.
|
|
66
|
+
* ```
|
|
67
|
+
* GET /spend-categories/{id}/ HTTP/1.1
|
|
68
|
+
* Host: rest.ripplingapis.com
|
|
69
|
+
* Accept: application/json
|
|
70
|
+
* Rippling-Api-Version: 2024-08-01
|
|
71
|
+
*
|
|
72
|
+
* HTTP/1.1 200 OK
|
|
73
|
+
* Content-Type: application/json
|
|
74
|
+
*
|
|
75
|
+
* {
|
|
76
|
+
* "__meta": {
|
|
77
|
+
* "redacted_fields": [
|
|
78
|
+
* {}
|
|
79
|
+
* ]
|
|
80
|
+
* }
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
retrieve(id: string, options?: RequestOptions): APIPromise<SpendCategoryRetrieveResponse> {
|
|
85
|
+
return this._client.get(path`/spend-categories/${id}/`, options);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type SpendCategoryListResponsesPageCursorURL = PageCursorURL<SpendCategoryListResponse>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A Spend category used to classify transaction line items.
|
|
93
|
+
*
|
|
94
|
+
* Inactive categories are included so historical transactions can still resolve their category.
|
|
95
|
+
*/
|
|
96
|
+
export interface SpendCategoryListResponse {
|
|
97
|
+
/**
|
|
98
|
+
* Identifier field
|
|
99
|
+
*/
|
|
100
|
+
id: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Record creation date
|
|
104
|
+
*/
|
|
105
|
+
created_at: string;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Record update date
|
|
109
|
+
*/
|
|
110
|
+
updated_at: string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Whether the category is active. Inactive categories remain available for
|
|
114
|
+
* historical references.
|
|
115
|
+
*/
|
|
116
|
+
active?: boolean;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Name of the Spend category.
|
|
120
|
+
*/
|
|
121
|
+
name?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Meta information for the response.
|
|
126
|
+
*/
|
|
127
|
+
export interface SpendCategoryRetrieveResponse extends BusinessPartnersAPI.Meta {
|
|
128
|
+
/**
|
|
129
|
+
* Identifier field
|
|
130
|
+
*/
|
|
131
|
+
id: string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Record creation date
|
|
135
|
+
*/
|
|
136
|
+
created_at: string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Record update date
|
|
140
|
+
*/
|
|
141
|
+
updated_at: string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Whether the category is active. Inactive categories remain available for
|
|
145
|
+
* historical references.
|
|
146
|
+
*/
|
|
147
|
+
active?: boolean;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Name of the Spend category.
|
|
151
|
+
*/
|
|
152
|
+
name?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface SpendCategoryListParams {
|
|
156
|
+
cursor?: string;
|
|
157
|
+
|
|
158
|
+
filter?: string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The maximum number of results to return. Defaults to 50. Maximum is 100.
|
|
162
|
+
*/
|
|
163
|
+
limit?: number;
|
|
164
|
+
|
|
165
|
+
order_by?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export declare namespace SpendCategories {
|
|
169
|
+
export {
|
|
170
|
+
type SpendCategoryListResponse as SpendCategoryListResponse,
|
|
171
|
+
type SpendCategoryRetrieveResponse as SpendCategoryRetrieveResponse,
|
|
172
|
+
type SpendCategoryListResponsesPageCursorURL as SpendCategoryListResponsesPageCursorURL,
|
|
173
|
+
type SpendCategoryListParams as SpendCategoryListParams,
|
|
174
|
+
};
|
|
175
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.2.0-alpha.
|
|
1
|
+
export const VERSION = '0.2.0-alpha.109'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.2.0-alpha.109";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.2.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.2.0-alpha.109";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '0.2.0-alpha.
|
|
4
|
+
exports.VERSION = '0.2.0-alpha.109'; // x-release-please-version
|
|
5
5
|
//# sourceMappingURL=version.js.map
|
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.2.0-alpha.
|
|
1
|
+
export const VERSION = '0.2.0-alpha.109'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|
package/lib/charts/guards.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type RuleNode, type Scalar } from "./types.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Assert `node` is shaped like a rule node — an object carrying a string `kind`.
|
|
4
|
-
* An unrecognised `kind` is *not* rejected here; that is the caller's `switch`
|
|
5
|
-
* default (`UnknownNodeError`), the deliberate "configured in code" signal.
|
|
6
|
-
*/
|
|
7
|
-
export declare function assertRuleNode(node: unknown): asserts node is RuleNode;
|
|
8
|
-
/**
|
|
9
|
-
* Read a `literal` node's `value`, rejecting a missing or non-scalar one. Without
|
|
10
|
-
* this, `{ kind: 'literal' }` resolves to `undefined` and slips past the caller.
|
|
11
|
-
*/
|
|
12
|
-
export declare function literalValue(node: {
|
|
13
|
-
value?: unknown;
|
|
14
|
-
}): Scalar;
|
|
15
|
-
//# sourceMappingURL=guards.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.mts","sourceRoot":"","sources":["../../src/lib/charts/guards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,oBAAgB;AAYrD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAStE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAQ9D"}
|
package/lib/charts/guards.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type RuleNode, type Scalar } from "./types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Assert `node` is shaped like a rule node — an object carrying a string `kind`.
|
|
4
|
-
* An unrecognised `kind` is *not* rejected here; that is the caller's `switch`
|
|
5
|
-
* default (`UnknownNodeError`), the deliberate "configured in code" signal.
|
|
6
|
-
*/
|
|
7
|
-
export declare function assertRuleNode(node: unknown): asserts node is RuleNode;
|
|
8
|
-
/**
|
|
9
|
-
* Read a `literal` node's `value`, rejecting a missing or non-scalar one. Without
|
|
10
|
-
* this, `{ kind: 'literal' }` resolves to `undefined` and slips past the caller.
|
|
11
|
-
*/
|
|
12
|
-
export declare function literalValue(node: {
|
|
13
|
-
value?: unknown;
|
|
14
|
-
}): Scalar;
|
|
15
|
-
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../../src/lib/charts/guards.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,mBAAgB;AAYrD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAStE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAQ9D"}
|
package/lib/charts/guards.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertRuleNode = assertRuleNode;
|
|
4
|
-
exports.literalValue = literalValue;
|
|
5
|
-
const errors_1 = require("./errors.js");
|
|
6
|
-
/**
|
|
7
|
-
* Runtime validation for one node of a deserialized, untrusted rule tree, shared
|
|
8
|
-
* by `evaluate` and `describe`. A rule can arrive from JSON that TypeScript never
|
|
9
|
-
* checked, so `null`, a non-object, or a node without a string `kind` would throw
|
|
10
|
-
* a native `TypeError` on the first field read — skipping the `ChartRuleError`
|
|
11
|
-
* escape hatch a caller relies on. Validate before reading fields.
|
|
12
|
-
*/
|
|
13
|
-
const SCALAR_TYPES = new Set(['number', 'string', 'boolean']);
|
|
14
|
-
/**
|
|
15
|
-
* Assert `node` is shaped like a rule node — an object carrying a string `kind`.
|
|
16
|
-
* An unrecognised `kind` is *not* rejected here; that is the caller's `switch`
|
|
17
|
-
* default (`UnknownNodeError`), the deliberate "configured in code" signal.
|
|
18
|
-
*/
|
|
19
|
-
function assertRuleNode(node) {
|
|
20
|
-
if (node === null ||
|
|
21
|
-
typeof node !== 'object' ||
|
|
22
|
-
Array.isArray(node) ||
|
|
23
|
-
typeof node.kind !== 'string') {
|
|
24
|
-
throw new errors_1.MalformedRuleError('a rule node must be an object with a string "kind"');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Read a `literal` node's `value`, rejecting a missing or non-scalar one. Without
|
|
29
|
-
* this, `{ kind: 'literal' }` resolves to `undefined` and slips past the caller.
|
|
30
|
-
*/
|
|
31
|
-
function literalValue(node) {
|
|
32
|
-
const { value } = node;
|
|
33
|
-
if (value === null || SCALAR_TYPES.has(typeof value)) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
throw new errors_1.MalformedRuleError(`a literal must carry a scalar value, got ${value === undefined ? 'undefined' : typeof value}`);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=guards.js.map
|
package/lib/charts/guards.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/lib/charts/guards.ts"],"names":[],"mappings":";;AAkBA,wCASC;AAMD,oCAQC;AAzCD,wCAA8C;AAG9C;;;;;;GAMG;AAEH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEnF;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAa;IAC1C,IACE,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACxB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,EACrD,CAAC;QACD,MAAM,IAAI,2BAAkB,CAAC,oDAAoD,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,YAAY,CAAC,IAAyB;IACpD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,KAAe,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,2BAAkB,CAC1B,4CAA4C,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAC/F,CAAC;AACJ,CAAC"}
|
package/lib/charts/guards.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { MalformedRuleError } from "./errors.mjs";
|
|
2
|
-
/**
|
|
3
|
-
* Runtime validation for one node of a deserialized, untrusted rule tree, shared
|
|
4
|
-
* by `evaluate` and `describe`. A rule can arrive from JSON that TypeScript never
|
|
5
|
-
* checked, so `null`, a non-object, or a node without a string `kind` would throw
|
|
6
|
-
* a native `TypeError` on the first field read — skipping the `ChartRuleError`
|
|
7
|
-
* escape hatch a caller relies on. Validate before reading fields.
|
|
8
|
-
*/
|
|
9
|
-
const SCALAR_TYPES = new Set(['number', 'string', 'boolean']);
|
|
10
|
-
/**
|
|
11
|
-
* Assert `node` is shaped like a rule node — an object carrying a string `kind`.
|
|
12
|
-
* An unrecognised `kind` is *not* rejected here; that is the caller's `switch`
|
|
13
|
-
* default (`UnknownNodeError`), the deliberate "configured in code" signal.
|
|
14
|
-
*/
|
|
15
|
-
export function assertRuleNode(node) {
|
|
16
|
-
if (node === null ||
|
|
17
|
-
typeof node !== 'object' ||
|
|
18
|
-
Array.isArray(node) ||
|
|
19
|
-
typeof node.kind !== 'string') {
|
|
20
|
-
throw new MalformedRuleError('a rule node must be an object with a string "kind"');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Read a `literal` node's `value`, rejecting a missing or non-scalar one. Without
|
|
25
|
-
* this, `{ kind: 'literal' }` resolves to `undefined` and slips past the caller.
|
|
26
|
-
*/
|
|
27
|
-
export function literalValue(node) {
|
|
28
|
-
const { value } = node;
|
|
29
|
-
if (value === null || SCALAR_TYPES.has(typeof value)) {
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
throw new MalformedRuleError(`a literal must carry a scalar value, got ${value === undefined ? 'undefined' : typeof value}`);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=guards.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"guards.mjs","sourceRoot":"","sources":["../../src/lib/charts/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAiB;AAG9C;;;;;;GAMG;AAEH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,IACE,IAAI,KAAK,IAAI;QACb,OAAO,IAAI,KAAK,QAAQ;QACxB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QACnB,OAAQ,IAA2B,CAAC,IAAI,KAAK,QAAQ,EACrD,CAAC;QACD,MAAM,IAAI,kBAAkB,CAAC,oDAAoD,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAyB;IACpD,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,KAAe,CAAC;IACzB,CAAC;IACD,MAAM,IAAI,kBAAkB,CAC1B,4CAA4C,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAC/F,CAAC;AACJ,CAAC"}
|
package/src/lib/charts/guards.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { MalformedRuleError } from './errors';
|
|
2
|
-
import { type RuleNode, type Scalar } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Runtime validation for one node of a deserialized, untrusted rule tree, shared
|
|
6
|
-
* by `evaluate` and `describe`. A rule can arrive from JSON that TypeScript never
|
|
7
|
-
* checked, so `null`, a non-object, or a node without a string `kind` would throw
|
|
8
|
-
* a native `TypeError` on the first field read — skipping the `ChartRuleError`
|
|
9
|
-
* escape hatch a caller relies on. Validate before reading fields.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const SCALAR_TYPES: ReadonlySet<string> = new Set(['number', 'string', 'boolean']);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Assert `node` is shaped like a rule node — an object carrying a string `kind`.
|
|
16
|
-
* An unrecognised `kind` is *not* rejected here; that is the caller's `switch`
|
|
17
|
-
* default (`UnknownNodeError`), the deliberate "configured in code" signal.
|
|
18
|
-
*/
|
|
19
|
-
export function assertRuleNode(node: unknown): asserts node is RuleNode {
|
|
20
|
-
if (
|
|
21
|
-
node === null ||
|
|
22
|
-
typeof node !== 'object' ||
|
|
23
|
-
Array.isArray(node) ||
|
|
24
|
-
typeof (node as { kind?: unknown }).kind !== 'string'
|
|
25
|
-
) {
|
|
26
|
-
throw new MalformedRuleError('a rule node must be an object with a string "kind"');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Read a `literal` node's `value`, rejecting a missing or non-scalar one. Without
|
|
32
|
-
* this, `{ kind: 'literal' }` resolves to `undefined` and slips past the caller.
|
|
33
|
-
*/
|
|
34
|
-
export function literalValue(node: { value?: unknown }): Scalar {
|
|
35
|
-
const { value } = node;
|
|
36
|
-
if (value === null || SCALAR_TYPES.has(typeof value)) {
|
|
37
|
-
return value as Scalar;
|
|
38
|
-
}
|
|
39
|
-
throw new MalformedRuleError(
|
|
40
|
-
`a literal must carry a scalar value, got ${value === undefined ? 'undefined' : typeof value}`,
|
|
41
|
-
);
|
|
42
|
-
}
|