@narrative.io/data-collaboration-sdk-ts 2.17.0 → 2.19.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/build/attributes/index.d.ts +16 -2
- package/build/attributes/index.js +28 -1
- package/build/base-api.js +1 -0
- package/build/index.d.ts +4 -3
- package/build/index.js +4 -2
- package/build/json-big-number/index.d.ts +29 -0
- package/build/json-big-number/index.js +34 -0
- package/build/json-big-number/lib/json-big-number.d.ts +7 -0
- package/build/json-big-number/lib/json-big-number.js +484 -0
- package/build/types.d.ts +8 -0
- package/package.json +11 -10
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseApi } from "../base-api";
|
|
2
|
-
import type { ApiRecords } from "../types";
|
|
2
|
+
import type { ApiRecords, ApiRecordsV2, PaginationOptions, SearchParams } from "../types";
|
|
3
3
|
import type { ArrayAttribute, Attribute, ObjectAttribute, PrimitiveAttribute, RefAttribute, ShallowAttribute, SubAttribute } from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* A class for accessing the Attribute API.
|
|
@@ -12,6 +12,20 @@ declare class AttributeApi extends BaseApi {
|
|
|
12
12
|
* @returns {Promise<ApiRecords<Attribute>>} A promise that resolves with the list of attributes.
|
|
13
13
|
*/
|
|
14
14
|
getAttributes(): Promise<ApiRecords<Attribute>>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A class for accessing the Attribute API.
|
|
18
|
+
* @extends BaseApi
|
|
19
|
+
*/
|
|
20
|
+
declare class AttributeApiV2 extends BaseApi {
|
|
21
|
+
/**
|
|
22
|
+
* Gets a list of attributes from the API.
|
|
23
|
+
*
|
|
24
|
+
* @param {PaginationOptions} [paginationOptions] - Optional pagination parameters.
|
|
25
|
+
* @param {SearchParams} [searchParams] - Optional search parameters.
|
|
26
|
+
* @returns {Promise<ApiRecordsV2<Attribute>>} A promise that resolves with the list of attributes.
|
|
27
|
+
*/
|
|
28
|
+
getAttributesV2(paginationOptions?: PaginationOptions, searchParams?: SearchParams): Promise<ApiRecordsV2<Attribute>>;
|
|
15
29
|
/**
|
|
16
30
|
* Gets a single attribute from the API by its ID.
|
|
17
31
|
*
|
|
@@ -34,4 +48,4 @@ declare class AttributeApi extends BaseApi {
|
|
|
34
48
|
*/
|
|
35
49
|
createAttribute(data: Attribute): Promise<Attribute>;
|
|
36
50
|
}
|
|
37
|
-
export { AttributeApi, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, };
|
|
51
|
+
export { AttributeApi, AttributeApiV2, type Attribute, type ShallowAttribute, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, };
|
|
@@ -19,6 +19,33 @@ class AttributeApi extends BaseApi {
|
|
|
19
19
|
async getAttributes() {
|
|
20
20
|
return await this.get(resourceName);
|
|
21
21
|
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A class for accessing the Attribute API.
|
|
25
|
+
* @extends BaseApi
|
|
26
|
+
*/
|
|
27
|
+
class AttributeApiV2 extends BaseApi {
|
|
28
|
+
/**
|
|
29
|
+
* Gets a list of attributes from the API.
|
|
30
|
+
*
|
|
31
|
+
* @param {PaginationOptions} [paginationOptions] - Optional pagination parameters.
|
|
32
|
+
* @param {SearchParams} [searchParams] - Optional search parameters.
|
|
33
|
+
* @returns {Promise<ApiRecordsV2<Attribute>>} A promise that resolves with the list of attributes.
|
|
34
|
+
*/
|
|
35
|
+
async getAttributesV2(paginationOptions, searchParams) {
|
|
36
|
+
const queryParams = new URLSearchParams();
|
|
37
|
+
if (paginationOptions?.page) {
|
|
38
|
+
queryParams.append("page", paginationOptions.page.toString());
|
|
39
|
+
}
|
|
40
|
+
if (paginationOptions?.per_page) {
|
|
41
|
+
queryParams.append("per_page", paginationOptions.per_page.toString());
|
|
42
|
+
}
|
|
43
|
+
if (searchParams?.q) {
|
|
44
|
+
queryParams.append("q", searchParams.q);
|
|
45
|
+
}
|
|
46
|
+
const url = `${resourceName}?${queryParams.toString()}`;
|
|
47
|
+
return await this.get(url);
|
|
48
|
+
}
|
|
22
49
|
/**
|
|
23
50
|
* Gets a single attribute from the API by its ID.
|
|
24
51
|
*
|
|
@@ -47,4 +74,4 @@ class AttributeApi extends BaseApi {
|
|
|
47
74
|
return await this.post(`${resourceName}`, data);
|
|
48
75
|
}
|
|
49
76
|
}
|
|
50
|
-
export { AttributeApi, };
|
|
77
|
+
export { AttributeApi, AttributeApiV2, };
|
package/build/base-api.js
CHANGED
package/build/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { AccessRuleSchema } from "./access-rules/types";
|
|
|
3
3
|
import { type AccessTokenMetadata, AccessTokensApi, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest } from "./access-tokens";
|
|
4
4
|
import { type Permission, resources } from "./access-tokens/types";
|
|
5
5
|
import { type App, AppsApi } from "./apps";
|
|
6
|
-
import { AttributeApi } from "./attributes";
|
|
6
|
+
import { AttributeApi, AttributeApiV2 } from "./attributes";
|
|
7
7
|
import type { ArrayAttribute, Attribute, ObjectAttribute, PrimitiveAttribute, RefAttribute, ShallowAttribute, SubAttribute } from "./attributes/types";
|
|
8
8
|
import { type ApiToken, AuthenticationApi, type LoggedInUser, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type StytchToken, type UserRole } from "./authentication";
|
|
9
9
|
import { BaseApi } from "./base-api";
|
|
@@ -20,6 +20,7 @@ import { HealthCheckApi } from "./health";
|
|
|
20
20
|
import type { HealthCheckResult } from "./health/types";
|
|
21
21
|
import { type Installation, InstallationsApi, type Profile } from "./installations";
|
|
22
22
|
import { type ExplainInput, type ExplainOutput, type GetJobsParameters, type Job, JobsApi, type MaterializedViewInput, type MaterializedViewOutput } from "./jobs";
|
|
23
|
+
import JsonBigNumber from "./json-big-number";
|
|
23
24
|
import { type Mapping, type MappingTestResult, MappingsApi } from "./mappings";
|
|
24
25
|
import type { CreateMapping, ObjectMapping, ValueMapping } from "./mappings/types";
|
|
25
26
|
import { type CompiledNql, type CreateMaterializedView, type Deduplication, type Explain, type Expression, type Nql, NqlApi, type NqlAst, type NqlBooleanExpression, type NqlCompileResult, type NqlExpression, type NqlField, type NqlFilterBinaryExpression, type NqlFilterExpression, type NqlFilterUnaryExpression, type NqlQueryInput, type NqlResult, type NqlWhere, type Raw, type Select, type Statement, type Table, compileStatement, parseStatement } from "./nql";
|
|
@@ -42,6 +43,6 @@ import { WhoAmIApi } from "./whoami";
|
|
|
42
43
|
import type { User } from "./whoami/types";
|
|
43
44
|
declare class NarrativeApi extends BaseApi {
|
|
44
45
|
}
|
|
45
|
-
interface NarrativeApi extends BaseApi, HealthCheckApi, AccessTokensApi, DataPlaneApi, DatasetApi, RosettaStoneApi, AttributeApi, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi {
|
|
46
|
+
interface NarrativeApi extends BaseApi, HealthCheckApi, AccessTokensApi, DataPlaneApi, DatasetApi, RosettaStoneApi, AttributeApi, AttributeApiV2, PingApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, MappingsApi, AccessRulesApi, AppsApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi {
|
|
46
47
|
}
|
|
47
|
-
export { NarrativeApi, AttributeApi, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, type DataPlane, type AccessTokenMetadata, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest, type App, type Resource, type AccessRuleV2, type GetAccessRulesParameters, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type Connection, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type ApiRecordsV2, type Dataset, type HealthCheckResult, type SampleRecords, type Permission, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type ColumnStatistics, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, type IngestDatasetFileRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type Profile, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type CompiledNql, type CreateMaterializedView, type GetJobsParameters, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table, type Nql, type NqlAst, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type ForecastResult, type CostForecastResult, type ForecastResultFailure, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type AstNodeType, type AstNodeMetadata, type SharedAccessRule, type OwnedAccessRule, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type AccessRuleSchema, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, type Job, type ExplainInput, type MaterializedViewInput, type ExplainOutput, type MaterializedViewOutput, type User, type Mapping, type MappingTestResult, type ValueMapping, type ObjectMapping, type CreateMapping, type CreateNqlQueryRequest, type UpdateNqlQueryRequest, type NqlQueryResponse, type NqlSharedQueryResponse, type NqlOwnedQueryResponse, type NqlQueryCollaborators, type NqlQueryOwner, type NqlQueryMetadata, compileStatement, parseStatement, };
|
|
48
|
+
export { NarrativeApi, AttributeApi, AttributeApiV2, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, type DataPlane, type AccessTokenMetadata, type CreateSystemAccessTokenRequest, type CreateSystemAccessTokenResponse, type UpdateSystemAccessTokenRequest, type App, type Resource, type AccessRuleV2, type GetAccessRulesParameters, type UploadsResponse, type PingStatus, type Attribute, type ShallowAttribute, type Connection, type RefAttribute, type SubAttribute, type PrimitiveAttribute, type ArrayAttribute, type ObjectAttribute, type Environment, type Config, type ApiRecords, type ApiRecordsV2, type Dataset, type HealthCheckResult, type SampleRecords, type Permission, type DatasetTableSummary, type DatasetTableSummaryAPIResponse, type UpdateDatasetRequest, type SchemaFileConfigType, type SchemaPropertiesType, type DatasetStatus, type DatasetWriteMode, type SchemaFileConfig, type SchemaProperties, type SchemaProperty, type SchemaPrimitiveProperty, type SchemaObjectProperty, type SchemaArrayProperty, type SchemaArrayItems, type SchemaArrayItemsPrimitive, type SchemaArrayItemsObject, type SchemaArrayItemsArray, type Schema, type AdvancedStatisticsMetadata, type SnapshotRange, type Configuration, type Columns, type ColumnSummary, type ColumnStatistics, type BasicStatistics, type AdvancedStatistics, type Histogram, type Value, type CreateDatasetRequest, type IngestDatasetFileRequest, type Product, type MonetaryAmount, type CompanyInfo, type Installation, type Profile, type FilePerSnapshotResponse, type BucketCreationRequest, type UpdateAccessTypeRequest, type CompiledNql, type CreateMaterializedView, type GetJobsParameters, type Deduplication, type Explain, type Expression, type Raw, type Select, type Statement, type Table, type Nql, type NqlAst, type NqlField, type NqlResult, type NqlQueryInput, type NqlCompileResult, type NqlExpression, type NqlWhere, type NqlFilterExpression, type NqlBooleanExpression, type NqlFilterBinaryExpression, type NqlFilterUnaryExpression, type DataStream, type DataRules, type ColumnSet, type ColumnWithFilterAndExport, type AttributeSet, type ForecastRequest, type ForecastResponse, type CostForecastRequest, type CostForecastResponse, type ForecastResult, type CostForecastResult, type ForecastResultFailure, type JobState, type ContractDetails, type CustomerContract, type PaymentMethod, type ContractRateView, type LoginRequest, type LoginResponse, type RegisterRequest, type RegisterResponse, type LoggedInUser, type StytchToken, type ApiToken, type UserRole, type RegistrationStatus, type RegistrationStatusRequest, type RegistrationStatusResponse, type ForecastBody, type AstNodeType, type AstNodeMetadata, type SharedAccessRule, type OwnedAccessRule, type ConversationAssistantMessage, type ConversationFunctionMessage, type ConversationIOMessage, type ConversationMessage, type ConversationMessageName, type ConversationMessageRole, type AccessRuleSchema, type ConversationMessages, type ConversationSystemMessage, type ConversationUserMessage, type RosettaRequestMessage, type ConversationMessageFunctionCall, type ConversationAssistantMessageWithFunctionCall, type RosettaResponseMessage, type ConversationAssistantMessageWithoutFunctionCall, type RetentionPolicy, type AccessRule, type Subscription, type SubscriptionDetails, type DataStreamSubscriptionDetails, type MarketplaceSubscriptionDetails, type SubscriptionOutput, type SubscriptionType, type SubscriptionStatus, type SubscriptionBudget, type Job, type ExplainInput, type MaterializedViewInput, type ExplainOutput, type MaterializedViewOutput, type User, type Mapping, type MappingTestResult, type ValueMapping, type ObjectMapping, type CreateMapping, type CreateNqlQueryRequest, type UpdateNqlQueryRequest, type NqlQueryResponse, type NqlSharedQueryResponse, type NqlOwnedQueryResponse, type NqlQueryCollaborators, type NqlQueryOwner, type NqlQueryMetadata, compileStatement, parseStatement, JsonBigNumber, };
|
package/build/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AccessRulesApi, } from "./access-rules/";
|
|
|
2
2
|
import { AccessTokensApi, } from "./access-tokens";
|
|
3
3
|
import { resources } from "./access-tokens/types";
|
|
4
4
|
import { AppsApi } from "./apps";
|
|
5
|
-
import { AttributeApi } from "./attributes";
|
|
5
|
+
import { AttributeApi, AttributeApiV2 } from "./attributes";
|
|
6
6
|
import { AuthenticationApi, } from "./authentication";
|
|
7
7
|
import { BaseApi } from "./base-api";
|
|
8
8
|
import { CompanyInfoApi } from "./company-info";
|
|
@@ -15,6 +15,7 @@ import { ForecastApi, } from "./forecast";
|
|
|
15
15
|
import { HealthCheckApi } from "./health";
|
|
16
16
|
import { InstallationsApi, } from "./installations";
|
|
17
17
|
import { JobsApi, } from "./jobs";
|
|
18
|
+
import JsonBigNumber from "./json-big-number";
|
|
18
19
|
import { MappingsApi } from "./mappings";
|
|
19
20
|
import { NqlApi, compileStatement, parseStatement, } from "./nql";
|
|
20
21
|
import { convertNqlObjectToForecastBody } from "./nql/DataRulesConverter";
|
|
@@ -39,6 +40,7 @@ applyMixins(NarrativeApi, [
|
|
|
39
40
|
DataPlaneApi,
|
|
40
41
|
RosettaStoneApi,
|
|
41
42
|
AttributeApi,
|
|
43
|
+
AttributeApiV2,
|
|
42
44
|
PingApi,
|
|
43
45
|
CompanyInfoApi,
|
|
44
46
|
InstallationsApi,
|
|
@@ -60,4 +62,4 @@ applyMixins(NarrativeApi, [
|
|
|
60
62
|
]);
|
|
61
63
|
export {
|
|
62
64
|
// biome-ignore lint/style/useExportType: We need to export the class
|
|
63
|
-
NarrativeApi, AttributeApi, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, compileStatement, parseStatement, };
|
|
65
|
+
NarrativeApi, AttributeApi, AttributeApiV2, AccessTokensApi, DataPlaneApi, HealthCheckApi, DatasetApi, PingApi, ProductsApi, CompanyInfoApi, InstallationsApi, ConnectionsApi, UploadsApi, ResourceApi, NqlApi, DataStreamsApi, ForecastApi, ContractsApi, AuthenticationApi, AppsApi, MappingsApi, AccessRulesApi, SubscriptionsApi, JobsApi, QueriesApi, WhoAmIApi, getNqlObject, buildNql, convertNqlObjectToForecastBody, isConversationAssistantMessage, isConversationFunctionMessage, isConversationInputMessage, isConversationMessage, isConversationMessageName, isConversationMessageRole, isConversationMessages, isConversationSystemMessage, isConversationUserMessage, isType, isConversationMessageFunctionCall, isConversationAssistantMessageWithFunctionCall, isRosettaRequestMessage, isConversationAssistantMessageWithoutFunctionCall, resources, compileStatement, parseStatement, JsonBigNumber, };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a JSON string and converts it into a JavaScript object or array.
|
|
3
|
+
* This function uses the `json-big-number` library, which supports parsing large numbers
|
|
4
|
+
* (BigNumbers) that may exceed JavaScript's safe integer range.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} source - The JSON string to parse.
|
|
7
|
+
* @param {(key: string, value: unknown) => unknown} [reviver] - An optional function that transforms the results.
|
|
8
|
+
* Each key/value pair is passed to this function, and its return value is used instead of the original value.
|
|
9
|
+
* @returns {unknown} - The JavaScript object or array resulting from parsing the JSON string.
|
|
10
|
+
*/
|
|
11
|
+
declare function parse(source: string, reviver?: (key: string, value: unknown) => unknown): unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Converts a JavaScript object or array into a JSON string.
|
|
14
|
+
* This function uses the `json-big-number` library, which supports serializing large numbers (BigNumbers)
|
|
15
|
+
* without losing precision, making it useful for cases where large numerical values need to be preserved.
|
|
16
|
+
*
|
|
17
|
+
* @param {unknown} value - The value to convert into a JSON string. This can be an object, array, or any other data type.
|
|
18
|
+
* @param {(key: string, value: unknown) => unknown} [replacer] - An optional function that can modify the behavior of the stringification process.
|
|
19
|
+
* If provided, it is called for each key/value pair.
|
|
20
|
+
* @param {string | number} [space] - An optional argument that controls indentation in the output JSON string.
|
|
21
|
+
* If a number, it specifies the number of spaces to indent. If a string, it specifies the characters to use for indentation.
|
|
22
|
+
* @returns {string} - The JSON string representation of the provided value.
|
|
23
|
+
*/
|
|
24
|
+
declare function stringify(value: unknown, replacer?: (key: string, value: unknown) => unknown, space?: string | number): string;
|
|
25
|
+
declare const JsonBigNumber: {
|
|
26
|
+
parse: typeof parse;
|
|
27
|
+
stringify: typeof stringify;
|
|
28
|
+
};
|
|
29
|
+
export default JsonBigNumber;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { parse as parseBigNumber, stringify as stringifyBigNumber, } from "./lib/json-big-number";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a JSON string and converts it into a JavaScript object or array.
|
|
4
|
+
* This function uses the `json-big-number` library, which supports parsing large numbers
|
|
5
|
+
* (BigNumbers) that may exceed JavaScript's safe integer range.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} source - The JSON string to parse.
|
|
8
|
+
* @param {(key: string, value: unknown) => unknown} [reviver] - An optional function that transforms the results.
|
|
9
|
+
* Each key/value pair is passed to this function, and its return value is used instead of the original value.
|
|
10
|
+
* @returns {unknown} - The JavaScript object or array resulting from parsing the JSON string.
|
|
11
|
+
*/
|
|
12
|
+
function parse(source, reviver) {
|
|
13
|
+
return parseBigNumber(source, reviver);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Converts a JavaScript object or array into a JSON string.
|
|
17
|
+
* This function uses the `json-big-number` library, which supports serializing large numbers (BigNumbers)
|
|
18
|
+
* without losing precision, making it useful for cases where large numerical values need to be preserved.
|
|
19
|
+
*
|
|
20
|
+
* @param {unknown} value - The value to convert into a JSON string. This can be an object, array, or any other data type.
|
|
21
|
+
* @param {(key: string, value: unknown) => unknown} [replacer] - An optional function that can modify the behavior of the stringification process.
|
|
22
|
+
* If provided, it is called for each key/value pair.
|
|
23
|
+
* @param {string | number} [space] - An optional argument that controls indentation in the output JSON string.
|
|
24
|
+
* If a number, it specifies the number of spaces to indent. If a string, it specifies the characters to use for indentation.
|
|
25
|
+
* @returns {string} - The JSON string representation of the provided value.
|
|
26
|
+
*/
|
|
27
|
+
function stringify(value, replacer, space) {
|
|
28
|
+
return stringifyBigNumber(value, replacer, space);
|
|
29
|
+
}
|
|
30
|
+
const JsonBigNumber = {
|
|
31
|
+
parse,
|
|
32
|
+
stringify,
|
|
33
|
+
};
|
|
34
|
+
export default JsonBigNumber;
|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// The MIT License (MIT)
|
|
3
|
+
// Copyright (c) 2017 William Buss
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
// in the Software without restriction, including without limitation the rights
|
|
7
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
// furnished to do so, subject to the following conditions:
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
// copies or substantial portions of the Software.
|
|
12
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
14
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
15
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
16
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
17
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
18
|
+
// SOFTWARE.
|
|
19
|
+
import BigNumber from "bignumber.js";
|
|
20
|
+
var rx_escapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
|
|
21
|
+
function f(n) {
|
|
22
|
+
// Format integers to have at least two digits.
|
|
23
|
+
return n < 10 ? "0" + n : n;
|
|
24
|
+
}
|
|
25
|
+
function this_value() {
|
|
26
|
+
return this.valueOf();
|
|
27
|
+
}
|
|
28
|
+
if (typeof Date.prototype.toJSON !== "function") {
|
|
29
|
+
Date.prototype.toJSON = function () {
|
|
30
|
+
return isFinite(this.valueOf())
|
|
31
|
+
? this.getUTCFullYear() +
|
|
32
|
+
"-" +
|
|
33
|
+
f(this.getUTCMonth() + 1) +
|
|
34
|
+
"-" +
|
|
35
|
+
f(this.getUTCDate()) +
|
|
36
|
+
"T" +
|
|
37
|
+
f(this.getUTCHours()) +
|
|
38
|
+
":" +
|
|
39
|
+
f(this.getUTCMinutes()) +
|
|
40
|
+
":" +
|
|
41
|
+
f(this.getUTCSeconds()) +
|
|
42
|
+
"Z"
|
|
43
|
+
: null;
|
|
44
|
+
};
|
|
45
|
+
Boolean.prototype.toJSON = this_value;
|
|
46
|
+
Number.prototype.toJSON = this_value;
|
|
47
|
+
String.prototype.toJSON = this_value;
|
|
48
|
+
}
|
|
49
|
+
var gap;
|
|
50
|
+
var indent;
|
|
51
|
+
var meta;
|
|
52
|
+
var rep;
|
|
53
|
+
function quote(string) {
|
|
54
|
+
// If the string contains no control characters, no quote characters, and no
|
|
55
|
+
// backslash characters, then we can safely slap some quotes around it.
|
|
56
|
+
// Otherwise we must also replace the offending characters with safe escape
|
|
57
|
+
// sequences.
|
|
58
|
+
rx_escapable.lastIndex = 0;
|
|
59
|
+
return rx_escapable.test(string)
|
|
60
|
+
? '"' +
|
|
61
|
+
string.replace(rx_escapable, (a) => {
|
|
62
|
+
var c = meta[a];
|
|
63
|
+
return typeof c === "string"
|
|
64
|
+
? c
|
|
65
|
+
: "\\u" + ("0000" + a.charCodeAt(0).toString(16)).slice(-4);
|
|
66
|
+
}) +
|
|
67
|
+
'"'
|
|
68
|
+
: '"' + string + '"';
|
|
69
|
+
}
|
|
70
|
+
function str(key, holder) {
|
|
71
|
+
// Produce a string from holder[key].
|
|
72
|
+
var i; // The loop counter.
|
|
73
|
+
var k; // The member key.
|
|
74
|
+
var v; // The member value.
|
|
75
|
+
var length;
|
|
76
|
+
var mind = gap;
|
|
77
|
+
var partial;
|
|
78
|
+
var value = holder[key];
|
|
79
|
+
var isBigNumber = value != null &&
|
|
80
|
+
(value instanceof BigNumber || BigNumber.isBigNumber(value));
|
|
81
|
+
// Check for NaN and Infinity
|
|
82
|
+
if (isBigNumber && !value.isFinite()) {
|
|
83
|
+
value = null;
|
|
84
|
+
}
|
|
85
|
+
// If the value has a toJSON method, call it to obtain a replacement value.
|
|
86
|
+
if (value &&
|
|
87
|
+
typeof value === "object" &&
|
|
88
|
+
typeof value.toJSON === "function") {
|
|
89
|
+
value = value.toJSON(key);
|
|
90
|
+
}
|
|
91
|
+
// If we were called with a replacer function, then call the replacer to
|
|
92
|
+
// obtain a replacement value.
|
|
93
|
+
if (typeof rep === "function") {
|
|
94
|
+
value = rep.call(holder, key, value);
|
|
95
|
+
}
|
|
96
|
+
// What happens next depends on the value's type.
|
|
97
|
+
switch (typeof value) {
|
|
98
|
+
case "string":
|
|
99
|
+
if (isBigNumber) {
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return quote(value);
|
|
104
|
+
}
|
|
105
|
+
case "number":
|
|
106
|
+
// JSON numbers must be finite. Encode non-finite numbers as null.
|
|
107
|
+
return isFinite(value) ? String(value) : "null";
|
|
108
|
+
case "boolean":
|
|
109
|
+
case "null":
|
|
110
|
+
// If the value is a boolean or null, convert it to a string. Note:
|
|
111
|
+
// typeof null does not produce "null". The case is included here in
|
|
112
|
+
// the remote chance that this gets fixed someday.
|
|
113
|
+
return String(value);
|
|
114
|
+
// If the type is "object", we might be dealing with an object or an array or
|
|
115
|
+
// null.
|
|
116
|
+
case "object":
|
|
117
|
+
// Due to a specification blunder in ECMAScript, typeof null is "object",
|
|
118
|
+
// so watch out for that case.
|
|
119
|
+
if (!value) {
|
|
120
|
+
return "null";
|
|
121
|
+
}
|
|
122
|
+
// Make an array to hold the partial results of stringifying this object value.
|
|
123
|
+
gap += indent;
|
|
124
|
+
partial = [];
|
|
125
|
+
// Is the value an array?
|
|
126
|
+
if (Object.prototype.toString.apply(value) === "[object Array]") {
|
|
127
|
+
// The value is an array. Stringify every element. Use null as a placeholder
|
|
128
|
+
// for non-JSON values.
|
|
129
|
+
length = value.length;
|
|
130
|
+
for (i = 0; i < length; i += 1) {
|
|
131
|
+
partial[i] = str(i, value) || "null";
|
|
132
|
+
}
|
|
133
|
+
// Join all of the elements together, separated with commas, and wrap them in
|
|
134
|
+
// brackets.
|
|
135
|
+
v =
|
|
136
|
+
partial.length === 0
|
|
137
|
+
? "[]"
|
|
138
|
+
: gap
|
|
139
|
+
? "[\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "]"
|
|
140
|
+
: "[" + partial.join(",") + "]";
|
|
141
|
+
gap = mind;
|
|
142
|
+
return v;
|
|
143
|
+
}
|
|
144
|
+
// If the replacer is an array, use it to select the members to be stringified.
|
|
145
|
+
if (rep && typeof rep === "object") {
|
|
146
|
+
length = rep.length;
|
|
147
|
+
for (i = 0; i < length; i += 1) {
|
|
148
|
+
if (typeof rep[i] === "string") {
|
|
149
|
+
k = rep[i];
|
|
150
|
+
v = str(k, value);
|
|
151
|
+
if (v) {
|
|
152
|
+
partial.push(quote(k) + (gap ? ": " : ":") + v);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
// Otherwise, iterate through all of the keys in the object.
|
|
159
|
+
for (k in value) {
|
|
160
|
+
if (Object.prototype.hasOwnProperty.call(value, k)) {
|
|
161
|
+
v = str(k, value);
|
|
162
|
+
if (v) {
|
|
163
|
+
partial.push(quote(k) + (gap ? ": " : ":") + v);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// Join all of the member texts together, separated with commas,
|
|
169
|
+
// and wrap them in braces.
|
|
170
|
+
v =
|
|
171
|
+
partial.length === 0
|
|
172
|
+
? "{}"
|
|
173
|
+
: gap
|
|
174
|
+
? "{\n" + gap + partial.join(",\n" + gap) + "\n" + mind + "}"
|
|
175
|
+
: "{" + partial.join(",") + "}";
|
|
176
|
+
gap = mind;
|
|
177
|
+
return v;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// If the JSON object does not yet have a stringify method, give it one.
|
|
181
|
+
meta = {
|
|
182
|
+
// table of character substitutions
|
|
183
|
+
"\b": "\\b",
|
|
184
|
+
"\t": "\\t",
|
|
185
|
+
"\n": "\\n",
|
|
186
|
+
"\f": "\\f",
|
|
187
|
+
"\r": "\\r",
|
|
188
|
+
'"': '\\"',
|
|
189
|
+
"\\": "\\\\",
|
|
190
|
+
};
|
|
191
|
+
export function stringify(value, replacer, space) {
|
|
192
|
+
// The stringify method takes a value and an optional replacer, and an optional
|
|
193
|
+
// space parameter, and returns a JSON text. The replacer can be a function
|
|
194
|
+
// that can replace values, or an array of strings that will select the keys.
|
|
195
|
+
// A default replacer method can be provided. Use of the space parameter can
|
|
196
|
+
// produce text that is more easily readable.
|
|
197
|
+
var i;
|
|
198
|
+
gap = "";
|
|
199
|
+
indent = "";
|
|
200
|
+
// If the space parameter is a number, make an indent string containing that
|
|
201
|
+
// many spaces.
|
|
202
|
+
if (typeof space === "number") {
|
|
203
|
+
for (i = 0; i < space; i += 1) {
|
|
204
|
+
indent += " ";
|
|
205
|
+
}
|
|
206
|
+
// If the space parameter is a string, it will be used as the indent string.
|
|
207
|
+
}
|
|
208
|
+
else if (typeof space === "string") {
|
|
209
|
+
indent = space;
|
|
210
|
+
}
|
|
211
|
+
// If there is a replacer, it must be a function or an array.
|
|
212
|
+
// Otherwise, throw an error.
|
|
213
|
+
rep = replacer;
|
|
214
|
+
if (replacer &&
|
|
215
|
+
typeof replacer !== "function" &&
|
|
216
|
+
(typeof replacer !== "object" || typeof replacer.length !== "number")) {
|
|
217
|
+
throw new Error("JSON.stringify");
|
|
218
|
+
}
|
|
219
|
+
// Make a fake root object containing our value under the key of "".
|
|
220
|
+
// Return the result of stringifying the value.
|
|
221
|
+
return str("", {
|
|
222
|
+
"": value,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// We are defining the function inside of another function to avoid creating
|
|
226
|
+
// global variables.
|
|
227
|
+
var at; // The index of the current character
|
|
228
|
+
var ch; // The current character
|
|
229
|
+
var escapee = {
|
|
230
|
+
'"': '"',
|
|
231
|
+
"\\": "\\",
|
|
232
|
+
"/": "/",
|
|
233
|
+
b: "\b",
|
|
234
|
+
f: "\f",
|
|
235
|
+
n: "\n",
|
|
236
|
+
r: "\r",
|
|
237
|
+
t: "\t",
|
|
238
|
+
};
|
|
239
|
+
var text;
|
|
240
|
+
var error = (m) => {
|
|
241
|
+
// Call error when something is wrong.
|
|
242
|
+
throw {
|
|
243
|
+
name: "SyntaxError",
|
|
244
|
+
message: m,
|
|
245
|
+
at: at,
|
|
246
|
+
text: text,
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
var next = (c) => {
|
|
250
|
+
// If a c parameter is provided, verify that it matches the current character.
|
|
251
|
+
if (c && c !== ch) {
|
|
252
|
+
error("Expected '" + c + "' instead of '" + ch + "'");
|
|
253
|
+
}
|
|
254
|
+
// Get the next character. When there are no more characters,
|
|
255
|
+
// return the empty string.
|
|
256
|
+
ch = text.charAt(at);
|
|
257
|
+
at += 1;
|
|
258
|
+
return ch;
|
|
259
|
+
};
|
|
260
|
+
var number = () => {
|
|
261
|
+
// Parse a number value to a BigNumber.
|
|
262
|
+
var number;
|
|
263
|
+
var string = "";
|
|
264
|
+
if (ch === "-") {
|
|
265
|
+
string = "-";
|
|
266
|
+
next("-");
|
|
267
|
+
}
|
|
268
|
+
while (ch >= "0" && ch <= "9") {
|
|
269
|
+
string += ch;
|
|
270
|
+
next();
|
|
271
|
+
}
|
|
272
|
+
if (ch === ".") {
|
|
273
|
+
string += ".";
|
|
274
|
+
while (next() && ch >= "0" && ch <= "9") {
|
|
275
|
+
string += ch;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (ch === "e" || ch === "E") {
|
|
279
|
+
string += ch;
|
|
280
|
+
next();
|
|
281
|
+
if (ch === "-" || ch === "+") {
|
|
282
|
+
string += ch;
|
|
283
|
+
next();
|
|
284
|
+
}
|
|
285
|
+
while (ch >= "0" && ch <= "9") {
|
|
286
|
+
string += ch;
|
|
287
|
+
next();
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
number = new BigNumber(string);
|
|
291
|
+
if (!number.isFinite()) {
|
|
292
|
+
error("Bad number");
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
return number;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
var string = () => {
|
|
299
|
+
// Parse a string value.
|
|
300
|
+
var hex;
|
|
301
|
+
var i;
|
|
302
|
+
var value = "";
|
|
303
|
+
var uffff;
|
|
304
|
+
// When parsing for string values, we must look for " and \ characters.
|
|
305
|
+
if (ch === '"') {
|
|
306
|
+
while (next()) {
|
|
307
|
+
if (ch === '"') {
|
|
308
|
+
next();
|
|
309
|
+
return value;
|
|
310
|
+
}
|
|
311
|
+
if (ch === "\\") {
|
|
312
|
+
next();
|
|
313
|
+
if (ch === "u") {
|
|
314
|
+
uffff = 0;
|
|
315
|
+
for (i = 0; i < 4; i += 1) {
|
|
316
|
+
hex = Number.parseInt(next(), 16);
|
|
317
|
+
if (!isFinite(hex)) {
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
uffff = uffff * 16 + hex;
|
|
321
|
+
}
|
|
322
|
+
value += String.fromCharCode(uffff);
|
|
323
|
+
}
|
|
324
|
+
else if (typeof escapee[ch] === "string") {
|
|
325
|
+
value += escapee[ch];
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
value += ch;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
error("Bad string");
|
|
337
|
+
};
|
|
338
|
+
var white = () => {
|
|
339
|
+
// Skip whitespace.
|
|
340
|
+
while (ch && ch <= " ") {
|
|
341
|
+
next();
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
var word = () => {
|
|
345
|
+
// true, false, or null.
|
|
346
|
+
switch (ch) {
|
|
347
|
+
case "t":
|
|
348
|
+
next("t");
|
|
349
|
+
next("r");
|
|
350
|
+
next("u");
|
|
351
|
+
next("e");
|
|
352
|
+
return true;
|
|
353
|
+
case "f":
|
|
354
|
+
next("f");
|
|
355
|
+
next("a");
|
|
356
|
+
next("l");
|
|
357
|
+
next("s");
|
|
358
|
+
next("e");
|
|
359
|
+
return false;
|
|
360
|
+
case "n":
|
|
361
|
+
next("n");
|
|
362
|
+
next("u");
|
|
363
|
+
next("l");
|
|
364
|
+
next("l");
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
error("Unexpected '" + ch + "'");
|
|
368
|
+
};
|
|
369
|
+
var value; // Place holder for the value function.
|
|
370
|
+
var array = () => {
|
|
371
|
+
// Parse an array value.
|
|
372
|
+
var arr = [];
|
|
373
|
+
if (ch === "[") {
|
|
374
|
+
next("[");
|
|
375
|
+
white();
|
|
376
|
+
if (ch === "]") {
|
|
377
|
+
next("]");
|
|
378
|
+
return arr; // empty array
|
|
379
|
+
}
|
|
380
|
+
while (ch) {
|
|
381
|
+
arr.push(value());
|
|
382
|
+
white();
|
|
383
|
+
if (ch === "]") {
|
|
384
|
+
next("]");
|
|
385
|
+
return arr;
|
|
386
|
+
}
|
|
387
|
+
next(",");
|
|
388
|
+
white();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
error("Bad array");
|
|
392
|
+
};
|
|
393
|
+
var object = () => {
|
|
394
|
+
// Parse an object value.
|
|
395
|
+
var key;
|
|
396
|
+
var obj = {};
|
|
397
|
+
if (ch === "{") {
|
|
398
|
+
next("{");
|
|
399
|
+
white();
|
|
400
|
+
if (ch === "}") {
|
|
401
|
+
next("}");
|
|
402
|
+
return obj; // empty object
|
|
403
|
+
}
|
|
404
|
+
while (ch) {
|
|
405
|
+
key = string();
|
|
406
|
+
white();
|
|
407
|
+
next(":");
|
|
408
|
+
if (Object.hasOwnProperty.call(obj, key)) {
|
|
409
|
+
error("Duplicate key '" + key + "'");
|
|
410
|
+
}
|
|
411
|
+
obj[key] = value();
|
|
412
|
+
white();
|
|
413
|
+
if (ch === "}") {
|
|
414
|
+
next("}");
|
|
415
|
+
return obj;
|
|
416
|
+
}
|
|
417
|
+
next(",");
|
|
418
|
+
white();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
error("Bad object");
|
|
422
|
+
};
|
|
423
|
+
value = () => {
|
|
424
|
+
// Parse a JSON value. It could be an object, an array, a string, a number,
|
|
425
|
+
// or a word.
|
|
426
|
+
white();
|
|
427
|
+
switch (ch) {
|
|
428
|
+
case "{":
|
|
429
|
+
return object();
|
|
430
|
+
case "[":
|
|
431
|
+
return array();
|
|
432
|
+
case '"':
|
|
433
|
+
return string();
|
|
434
|
+
case "-":
|
|
435
|
+
return number();
|
|
436
|
+
default:
|
|
437
|
+
return ch >= "0" && ch <= "9" ? number() : word();
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
// Set the New JSONBigNumber.parse function It will have access to all of the above
|
|
441
|
+
// functions and variables.
|
|
442
|
+
export function parse(source, reviver) {
|
|
443
|
+
var result;
|
|
444
|
+
text = source;
|
|
445
|
+
at = 0;
|
|
446
|
+
ch = " ";
|
|
447
|
+
result = value();
|
|
448
|
+
white();
|
|
449
|
+
if (ch) {
|
|
450
|
+
error("Syntax error");
|
|
451
|
+
}
|
|
452
|
+
// If there is a reviver function, we recursively walk the new structure,
|
|
453
|
+
// passing each name/value pair to the reviver function for possible
|
|
454
|
+
// transformation, starting with a temporary root object that holds the result
|
|
455
|
+
// in an empty key. If there is not a reviver function, we simply return the
|
|
456
|
+
// result.
|
|
457
|
+
return typeof reviver === "function"
|
|
458
|
+
? (function walk(holder, key) {
|
|
459
|
+
var k;
|
|
460
|
+
var v;
|
|
461
|
+
var val = holder[key];
|
|
462
|
+
if (val && typeof val === "object") {
|
|
463
|
+
for (k in val) {
|
|
464
|
+
if (Object.prototype.hasOwnProperty.call(val, k)) {
|
|
465
|
+
v = walk(val, k);
|
|
466
|
+
if (v !== undefined) {
|
|
467
|
+
val[k] = v;
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
delete val[k];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return reviver.call(holder, key, val);
|
|
476
|
+
})({
|
|
477
|
+
"": result,
|
|
478
|
+
}, "")
|
|
479
|
+
: result;
|
|
480
|
+
}
|
|
481
|
+
export default {
|
|
482
|
+
parse: parse,
|
|
483
|
+
stringify: stringify,
|
|
484
|
+
};
|
package/build/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ResponseAsTypes } from "mande";
|
|
1
2
|
/**
|
|
2
3
|
* Environment for the API.
|
|
3
4
|
*
|
|
@@ -16,6 +17,7 @@ export interface Config {
|
|
|
16
17
|
environment?: Environment;
|
|
17
18
|
headers?: Record<string, string>;
|
|
18
19
|
verbose?: boolean;
|
|
20
|
+
responseAs?: ResponseAsTypes;
|
|
19
21
|
}
|
|
20
22
|
export interface ApiRecordsV2<T> extends PaginationMetadata {
|
|
21
23
|
records: T[];
|
|
@@ -44,4 +46,10 @@ export interface PaginationOptions {
|
|
|
44
46
|
page?: number | null;
|
|
45
47
|
per_page?: number | null;
|
|
46
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Interface for search parameters
|
|
51
|
+
*/
|
|
52
|
+
export interface SearchParams {
|
|
53
|
+
q?: string;
|
|
54
|
+
}
|
|
47
55
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narrative.io/data-collaboration-sdk-ts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.0",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"repository": "github:narrative-io/data-collaboration-sdk-ts",
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
|
-
"lint": "npx @biomejs/biome check --
|
|
12
|
-
"prepare": "npx @biomejs/biome check --
|
|
11
|
+
"lint": "npx @biomejs/biome check --write ./src",
|
|
12
|
+
"prepare": "npx @biomejs/biome check --write ./src && npm run build",
|
|
13
13
|
"prepublishOnly": "npm test && npm run lint",
|
|
14
14
|
"preversion": "npm run lint",
|
|
15
15
|
"version": "npm run && git add -A src",
|
|
@@ -20,21 +20,22 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@babel/core": "7.25.
|
|
24
|
-
"@babel/preset-env": "7.25.
|
|
25
|
-
"@babel/preset-typescript": "7.
|
|
26
|
-
"@biomejs/biome": "1.9.
|
|
23
|
+
"@babel/core": "7.25.8",
|
|
24
|
+
"@babel/preset-env": "7.25.8",
|
|
25
|
+
"@babel/preset-typescript": "7.25.7",
|
|
26
|
+
"@biomejs/biome": "1.9.3",
|
|
27
27
|
"@commitlint/cli": "19.5.0",
|
|
28
28
|
"@commitlint/config-conventional": "19.5.0",
|
|
29
29
|
"@types/jest": "29.5.13",
|
|
30
30
|
"babel-jest": "29.7.0",
|
|
31
31
|
"jest": "29.7.0",
|
|
32
|
-
"lefthook": "1.7.
|
|
32
|
+
"lefthook": "1.7.18",
|
|
33
33
|
"ts-jest": "29.2.5"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"mande": "2.0.9",
|
|
37
|
-
"zod": "3.23.8"
|
|
37
|
+
"zod": "3.23.8",
|
|
38
|
+
"bignumber.js": "^9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"overrides": {
|
|
40
41
|
"semver@<7.5.2": "7.5.2"
|
|
@@ -42,4 +43,4 @@
|
|
|
42
43
|
"files": [
|
|
43
44
|
"build"
|
|
44
45
|
]
|
|
45
|
-
}
|
|
46
|
+
}
|