powersync 0.1.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/README.md +339 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +9 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +8 -0
- package/dist/commands/init.d.ts +7 -0
- package/dist/commands/init.js +49 -0
- package/dist/commands/instance/config.d.ts +6 -0
- package/dist/commands/instance/config.js +23 -0
- package/dist/commands/instance/create.d.ts +16 -0
- package/dist/commands/instance/create.js +163 -0
- package/dist/commands/instance/deploy.d.ts +15 -0
- package/dist/commands/instance/deploy.js +142 -0
- package/dist/commands/instance/destroy.d.ts +9 -0
- package/dist/commands/instance/destroy.js +42 -0
- package/dist/commands/instance/schema.d.ts +6 -0
- package/dist/commands/instance/schema.js +20 -0
- package/dist/commands/instance/set.d.ts +9 -0
- package/dist/commands/instance/set.js +31 -0
- package/dist/commands/instance/status.d.ts +6 -0
- package/dist/commands/instance/status.js +21 -0
- package/dist/commands/instance/stop.d.ts +9 -0
- package/dist/commands/instance/stop.js +42 -0
- package/dist/commands/instance/sync-rules/deploy.d.ts +10 -0
- package/dist/commands/instance/sync-rules/deploy.js +49 -0
- package/dist/commands/instance/sync-rules/generate-schema.d.ts +10 -0
- package/dist/commands/instance/sync-rules/generate-schema.js +55 -0
- package/dist/commands/instance/sync-rules/validate.d.ts +9 -0
- package/dist/commands/instance/sync-rules/validate.js +29 -0
- package/dist/commands/instances.d.ts +6 -0
- package/dist/commands/instances.js +20 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/powersync-sdk/accounts/api.d.ts +717 -0
- package/dist/powersync-sdk/accounts/api.js +182 -0
- package/dist/powersync-sdk/accounts/client.d.ts +1096 -0
- package/dist/powersync-sdk/accounts/client.js +124 -0
- package/dist/powersync-sdk/accounts/codecs.d.ts +32 -0
- package/dist/powersync-sdk/accounts/codecs.js +93 -0
- package/dist/powersync-sdk/accounts/index.d.ts +4 -0
- package/dist/powersync-sdk/accounts/index.js +4 -0
- package/dist/powersync-sdk/accounts/models.d.ts +260 -0
- package/dist/powersync-sdk/accounts/models.js +96 -0
- package/dist/powersync-sdk/accounts/routes.d.ts +44 -0
- package/dist/powersync-sdk/accounts/routes.js +45 -0
- package/dist/powersync-sdk/accounts/source.d.ts +76 -0
- package/dist/powersync-sdk/accounts/source.js +32 -0
- package/dist/powersync-sdk/errors/errors.d.ts +62 -0
- package/dist/powersync-sdk/errors/errors.js +115 -0
- package/dist/powersync-sdk/errors/index.d.ts +2 -0
- package/dist/powersync-sdk/errors/index.js +2 -0
- package/dist/powersync-sdk/errors/utils.d.ts +4 -0
- package/dist/powersync-sdk/errors/utils.js +18 -0
- package/dist/powersync-sdk/fetch-clients/codecs.d.ts +4 -0
- package/dist/powersync-sdk/fetch-clients/codecs.js +34 -0
- package/dist/powersync-sdk/fetch-clients/decoders.d.ts +3 -0
- package/dist/powersync-sdk/fetch-clients/decoders.js +35 -0
- package/dist/powersync-sdk/fetch-clients/definitions.d.ts +97 -0
- package/dist/powersync-sdk/fetch-clients/definitions.js +22 -0
- package/dist/powersync-sdk/fetch-clients/errors.d.ts +7 -0
- package/dist/powersync-sdk/fetch-clients/errors.js +19 -0
- package/dist/powersync-sdk/fetch-clients/index.d.ts +5 -0
- package/dist/powersync-sdk/fetch-clients/index.js +5 -0
- package/dist/powersync-sdk/fetch-clients/node-client.d.ts +9 -0
- package/dist/powersync-sdk/fetch-clients/node-client.js +107 -0
- package/dist/powersync-sdk/fetch-clients/request.d.ts +11 -0
- package/dist/powersync-sdk/fetch-clients/request.js +138 -0
- package/dist/powersync-sdk/fetch-clients/streaming.d.ts +65 -0
- package/dist/powersync-sdk/fetch-clients/streaming.js +99 -0
- package/dist/powersync-sdk/fetch-clients/utils.d.ts +13 -0
- package/dist/powersync-sdk/fetch-clients/utils.js +43 -0
- package/dist/powersync-sdk/fetch-clients/web-client.d.ts +14 -0
- package/dist/powersync-sdk/fetch-clients/web-client.js +56 -0
- package/dist/powersync-sdk/json/index.d.ts +4 -0
- package/dist/powersync-sdk/json/index.js +3 -0
- package/dist/powersync-sdk/json/json.d.ts +5 -0
- package/dist/powersync-sdk/json/json.js +35 -0
- package/dist/powersync-sdk/json/json_container.d.ts +18 -0
- package/dist/powersync-sdk/json/json_container.js +28 -0
- package/dist/powersync-sdk/json/json_stringify.d.ts +36 -0
- package/dist/powersync-sdk/json/json_stringify.js +162 -0
- package/dist/powersync-sdk/powersync/client.d.ts +449 -0
- package/dist/powersync-sdk/powersync/client.js +53 -0
- package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +327 -0
- package/dist/powersync-sdk/powersync/config/HostedConfig.js +92 -0
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +211 -0
- package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +97 -0
- package/dist/powersync-sdk/powersync/config/normalize.d.ts +32 -0
- package/dist/powersync-sdk/powersync/config/normalize.js +85 -0
- package/dist/powersync-sdk/powersync/definitions.d.ts +149 -0
- package/dist/powersync-sdk/powersync/definitions.js +97 -0
- package/dist/powersync-sdk/powersync/index.d.ts +8 -0
- package/dist/powersync-sdk/powersync/index.js +8 -0
- package/dist/powersync-sdk/powersync/internal_routes.d.ts +247 -0
- package/dist/powersync-sdk/powersync/internal_routes.js +69 -0
- package/dist/powersync-sdk/powersync/routes.d.ts +779 -0
- package/dist/powersync-sdk/powersync/routes.js +191 -0
- package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +31 -0
- package/dist/powersync-sdk/sdk-clients/endpoints.js +48 -0
- package/dist/powersync-sdk/sdk-clients/index.d.ts +3 -0
- package/dist/powersync-sdk/sdk-clients/index.js +3 -0
- package/dist/powersync-sdk/sdk-clients/pagination.d.ts +14 -0
- package/dist/powersync-sdk/sdk-clients/pagination.js +21 -0
- package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +17 -0
- package/dist/powersync-sdk/sdk-clients/sdk-client.js +30 -0
- package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +31 -0
- package/dist/powersync-sdk/streaming/bson/buffer-array.js +79 -0
- package/dist/powersync-sdk/streaming/bson/constants.d.ts +2 -0
- package/dist/powersync-sdk/streaming/bson/constants.js +1 -0
- package/dist/powersync-sdk/streaming/bson/decoder.d.ts +10 -0
- package/dist/powersync-sdk/streaming/bson/decoder.js +62 -0
- package/dist/powersync-sdk/streaming/bson/encoder.d.ts +10 -0
- package/dist/powersync-sdk/streaming/bson/encoder.js +23 -0
- package/dist/powersync-sdk/streaming/bson/header.d.ts +11 -0
- package/dist/powersync-sdk/streaming/bson/header.js +52 -0
- package/dist/powersync-sdk/streaming/bson/index.d.ts +5 -0
- package/dist/powersync-sdk/streaming/bson/index.js +5 -0
- package/dist/powersync-sdk/streaming/core/backpressure.d.ts +15 -0
- package/dist/powersync-sdk/streaming/core/backpressure.js +34 -0
- package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +6 -0
- package/dist/powersync-sdk/streaming/core/cross-stream.js +17 -0
- package/dist/powersync-sdk/streaming/core/index.d.ts +4 -0
- package/dist/powersync-sdk/streaming/core/index.js +4 -0
- package/dist/powersync-sdk/streaming/core/node-utils.d.ts +7 -0
- package/dist/powersync-sdk/streaming/core/node-utils.js +11 -0
- package/dist/powersync-sdk/streaming/core/transformers.d.ts +41 -0
- package/dist/powersync-sdk/streaming/core/transformers.js +70 -0
- package/dist/powersync-sdk/streaming/core/utils.d.ts +36 -0
- package/dist/powersync-sdk/streaming/core/utils.js +66 -0
- package/dist/powersync-sdk/streaming/index.d.ts +3 -0
- package/dist/powersync-sdk/streaming/index.js +3 -0
- package/dist/powersync-sdk/streaming/web.d.ts +4 -0
- package/dist/powersync-sdk/streaming/web.js +4 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +36 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +58 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +18 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +348 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +118 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +131 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +134 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +122 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +158 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +14 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +165 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +11 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +207 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +30 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +29 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +2 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +111 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +9 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +9 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +5 -0
- package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +9 -0
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +12 -0
- package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +35 -0
- package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +33 -0
- package/dist/powersync-sdk/sync-rules/ExpressionType.js +62 -0
- package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +4 -0
- package/dist/powersync-sdk/sync-rules/IdSequence.js +7 -0
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +12 -0
- package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +38 -0
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +14 -0
- package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +24 -0
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +5 -0
- package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +1 -0
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +37 -0
- package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +116 -0
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +39 -0
- package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +245 -0
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +43 -0
- package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +254 -0
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +52 -0
- package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +252 -0
- package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +26 -0
- package/dist/powersync-sdk/sync-rules/StaticSchema.js +71 -0
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +24 -0
- package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +71 -0
- package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +17 -0
- package/dist/powersync-sdk/sync-rules/TablePattern.js +56 -0
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +9 -0
- package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +41 -0
- package/dist/powersync-sdk/sync-rules/errors.d.ts +22 -0
- package/dist/powersync-sdk/sync-rules/errors.js +60 -0
- package/dist/powersync-sdk/sync-rules/generators.d.ts +6 -0
- package/dist/powersync-sdk/sync-rules/generators.js +6 -0
- package/dist/powersync-sdk/sync-rules/index.d.ts +17 -0
- package/dist/powersync-sdk/sync-rules/index.js +17 -0
- package/dist/powersync-sdk/sync-rules/json_schema.d.ts +3 -0
- package/dist/powersync-sdk/sync-rules/json_schema.js +50 -0
- package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +91 -0
- package/dist/powersync-sdk/sync-rules/sql_filters.js +491 -0
- package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +53 -0
- package/dist/powersync-sdk/sync-rules/sql_functions.js +755 -0
- package/dist/powersync-sdk/sync-rules/sql_support.d.ts +22 -0
- package/dist/powersync-sdk/sync-rules/sql_support.js +208 -0
- package/dist/powersync-sdk/sync-rules/types.d.ts +174 -0
- package/dist/powersync-sdk/sync-rules/types.js +9 -0
- package/dist/powersync-sdk/sync-rules/utils.d.ts +45 -0
- package/dist/powersync-sdk/sync-rules/utils.js +163 -0
- package/dist/service/accounts.client.d.ts +26 -0
- package/dist/service/accounts.client.js +26 -0
- package/dist/service/powersync.client.d.ts +269 -0
- package/dist/service/powersync.client.js +135 -0
- package/dist/service/types.d.ts +69 -0
- package/dist/service/types.js +1 -0
- package/dist/service/utils.d.ts +5 -0
- package/dist/service/utils.js +7 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.js +52 -0
- package/oclif.manifest.json +514 -0
- package/package.json +81 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export var ROUTES;
|
|
2
|
+
(function (ROUTES) {
|
|
3
|
+
ROUTES["ACCEPT_INVITE"] = "/api/accounts/v5/invites/accept";
|
|
4
|
+
ROUTES["COMPLETE_SIGNUP"] = "/api/accounts/v5/trial/complete-signup";
|
|
5
|
+
ROUTES["CREATE_APP"] = "/api/accounts/v5/apps/create";
|
|
6
|
+
ROUTES["CREATE_DEV_INVITE"] = "/api/accounts/v5/invites/create";
|
|
7
|
+
ROUTES["CREATE_ORG"] = "/api/accounts/v5/organizations/create";
|
|
8
|
+
ROUTES["CREATE_USER"] = "/api/accounts/v5/users/create";
|
|
9
|
+
ROUTES["DECLINE_INVITE"] = "/api/accounts/v5/invites/decline";
|
|
10
|
+
ROUTES["DELETE_APP"] = "/api/accounts/v5/apps/delete";
|
|
11
|
+
ROUTES["DELETE_MFA_FACTOR"] = "/me/profile/delete_factor";
|
|
12
|
+
ROUTES["DELETE_USER"] = "/api/accounts/v5/users/delete";
|
|
13
|
+
ROUTES["DESTROY_INVITE"] = "/api/accounts/v5/invites/destroy";
|
|
14
|
+
ROUTES["DOWNGRADE_ORG"] = "/api/accounts/v5/organizations/downgrade";
|
|
15
|
+
ROUTES["GENERATE_MFA_BACKUP_CODES"] = "/me/profile/generate_backup_codes";
|
|
16
|
+
ROUTES["GET_APP"] = "/api/accounts/v5/apps/get";
|
|
17
|
+
ROUTES["GET_ORG"] = "/api/accounts/v5/organizations/get";
|
|
18
|
+
ROUTES["GET_PREFERRED_FACTOR"] = "/me/profile/get_preferred_factor";
|
|
19
|
+
ROUTES["GET_SENSITIVE_ACCESS_TOKEN"] = "/me/profile/auth_for_token";
|
|
20
|
+
ROUTES["GET_TRIAL_USER"] = "/api/accounts/v5/trial/get-user";
|
|
21
|
+
ROUTES["GET_USER"] = "/api/accounts/v5/users/get";
|
|
22
|
+
ROUTES["GET_USER_INVITES"] = "/api/accounts/v5/invites/user-invites";
|
|
23
|
+
ROUTES["GIVE_USER_ACCESS"] = "/api/accounts/v5/organizations/give-user-access";
|
|
24
|
+
ROUTES["LIST_APPS"] = "/api/accounts/v5/apps/list";
|
|
25
|
+
ROUTES["LIST_DEV_INVITES"] = "/api/accounts/v5/invites/list";
|
|
26
|
+
ROUTES["LIST_MFA_FACTORS"] = "/me/profile/list_mfa_factors";
|
|
27
|
+
ROUTES["LIST_ORGS"] = "/api/accounts/v5/organizations/list";
|
|
28
|
+
ROUTES["LIST_USERS"] = "/api/accounts/v5/users/list";
|
|
29
|
+
ROUTES["PROVISION_USER_TOKEN"] = "/api/accounts/v5/trial/provision-user-token";
|
|
30
|
+
ROUTES["REGISTER_SMS_USER_MFA_FACTOR"] = "/me/profile/register_sms_factor";
|
|
31
|
+
ROUTES["REGISTER_TOTP_USER_MFA_FACTOR"] = "/me/profile/register_totp_factor";
|
|
32
|
+
ROUTES["SEARCH_APPS"] = "/api/accounts/v5/apps/search";
|
|
33
|
+
ROUTES["SEARCH_ORGS"] = "/api/accounts/v5/organizations/search";
|
|
34
|
+
ROUTES["SEARCH_USERS"] = "/api/accounts/v5/users/search";
|
|
35
|
+
ROUTES["SEND_MFA_SMS"] = "/me/profile/request_otp_sms";
|
|
36
|
+
ROUTES["SET_PREFERRED_MFA_METHOD"] = "/me/profile/set_preferred_factor";
|
|
37
|
+
ROUTES["START_TRIAL"] = "/api/accounts/v5/trial/start";
|
|
38
|
+
ROUTES["UPDATE_APP"] = "/api/accounts/v5/apps/update";
|
|
39
|
+
ROUTES["UPDATE_INVITE"] = "/api/accounts/v5/invites/update";
|
|
40
|
+
ROUTES["UPDATE_ORG"] = "/api/accounts/v5/organizations/update";
|
|
41
|
+
ROUTES["UPDATE_ORG_BILLING"] = "/api/accounts/v5/organizations/update-billing";
|
|
42
|
+
ROUTES["UPDATE_USER"] = "/api/accounts/v5/users/update";
|
|
43
|
+
ROUTES["UPGRADE_ORG"] = "/api/accounts/v5/organizations/upgrade";
|
|
44
|
+
ROUTES["VERIFY_MFA_FACTOR"] = "/me/profile/verify_factor";
|
|
45
|
+
})(ROUTES || (ROUTES = {}));
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
export declare enum SourceType {
|
|
3
|
+
AzureDevops = "AZURE_DEVOPS",
|
|
4
|
+
GitHub = "GITHUB",
|
|
5
|
+
Internal = "INTERNAL"
|
|
6
|
+
}
|
|
7
|
+
export declare const GitHubSourceProperties: t.ObjectCodec<{
|
|
8
|
+
owner: t.IdentityCodec<t.CodecType.String>;
|
|
9
|
+
repo: t.IdentityCodec<t.CodecType.String>;
|
|
10
|
+
}>;
|
|
11
|
+
export type GitHubSourceProperties = t.Encoded<typeof GitHubSourceProperties>;
|
|
12
|
+
export declare const GitHubSourceMetadata: t.ObjectCodec<{
|
|
13
|
+
properties: t.ObjectCodec<{
|
|
14
|
+
owner: t.IdentityCodec<t.CodecType.String>;
|
|
15
|
+
repo: t.IdentityCodec<t.CodecType.String>;
|
|
16
|
+
}>;
|
|
17
|
+
type: t.LiteralCodec<SourceType.GitHub>;
|
|
18
|
+
}>;
|
|
19
|
+
export type GitHubSourceMetadata = t.Encoded<typeof GitHubSourceMetadata>;
|
|
20
|
+
export declare const InternalSourceProperties: t.ObjectCodec<{
|
|
21
|
+
id: t.IdentityCodec<t.CodecType.String>;
|
|
22
|
+
}>;
|
|
23
|
+
export type InternalSourceProperties = t.Encoded<typeof InternalSourceProperties>;
|
|
24
|
+
export declare const InternalSourceMetadata: t.ObjectCodec<{
|
|
25
|
+
properties: t.ObjectCodec<{
|
|
26
|
+
id: t.IdentityCodec<t.CodecType.String>;
|
|
27
|
+
}>;
|
|
28
|
+
type: t.LiteralCodec<SourceType.Internal>;
|
|
29
|
+
}>;
|
|
30
|
+
export type InternalSourceMetadata = t.Encoded<typeof InternalSourceMetadata>;
|
|
31
|
+
export declare const AzureDevopsSourceProperties: t.ObjectCodec<{
|
|
32
|
+
organization: t.IdentityCodec<t.CodecType.String>;
|
|
33
|
+
project: t.IdentityCodec<t.CodecType.String>;
|
|
34
|
+
repo: t.IdentityCodec<t.CodecType.String>;
|
|
35
|
+
}>;
|
|
36
|
+
export type AzureDevopsSourceProperties = t.Encoded<typeof AzureDevopsSourceProperties>;
|
|
37
|
+
export declare const AzureDevopsSourceMetadata: t.ObjectCodec<{
|
|
38
|
+
properties: t.ObjectCodec<{
|
|
39
|
+
organization: t.IdentityCodec<t.CodecType.String>;
|
|
40
|
+
project: t.IdentityCodec<t.CodecType.String>;
|
|
41
|
+
repo: t.IdentityCodec<t.CodecType.String>;
|
|
42
|
+
}>;
|
|
43
|
+
type: t.LiteralCodec<SourceType.AzureDevops>;
|
|
44
|
+
}>;
|
|
45
|
+
export type AzureDevopsSourceMetadata = t.Encoded<typeof AzureDevopsSourceMetadata>;
|
|
46
|
+
export declare const SourceMetadata: t.Union<t.Codec<{
|
|
47
|
+
type: SourceType.GitHub;
|
|
48
|
+
properties: {
|
|
49
|
+
repo: string;
|
|
50
|
+
owner: string;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
type: SourceType.Internal;
|
|
54
|
+
properties: {
|
|
55
|
+
id: string;
|
|
56
|
+
};
|
|
57
|
+
}, {
|
|
58
|
+
type: SourceType.GitHub;
|
|
59
|
+
properties: {
|
|
60
|
+
repo: string;
|
|
61
|
+
owner: string;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
type: SourceType.Internal;
|
|
65
|
+
properties: {
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
}, string, t.CodecProps>, t.ObjectCodec<{
|
|
69
|
+
properties: t.ObjectCodec<{
|
|
70
|
+
organization: t.IdentityCodec<t.CodecType.String>;
|
|
71
|
+
project: t.IdentityCodec<t.CodecType.String>;
|
|
72
|
+
repo: t.IdentityCodec<t.CodecType.String>;
|
|
73
|
+
}>;
|
|
74
|
+
type: t.LiteralCodec<SourceType.AzureDevops>;
|
|
75
|
+
}>>;
|
|
76
|
+
export type SourceMetadata = t.Encoded<typeof SourceMetadata>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as t from 'ts-codec';
|
|
2
|
+
export var SourceType;
|
|
3
|
+
(function (SourceType) {
|
|
4
|
+
SourceType["AzureDevops"] = "AZURE_DEVOPS";
|
|
5
|
+
SourceType["GitHub"] = "GITHUB";
|
|
6
|
+
SourceType["Internal"] = "INTERNAL";
|
|
7
|
+
})(SourceType || (SourceType = {}));
|
|
8
|
+
export const GitHubSourceProperties = t.object({
|
|
9
|
+
owner: t.string,
|
|
10
|
+
repo: t.string
|
|
11
|
+
});
|
|
12
|
+
export const GitHubSourceMetadata = t.object({
|
|
13
|
+
properties: GitHubSourceProperties,
|
|
14
|
+
type: t.literal(SourceType.GitHub)
|
|
15
|
+
});
|
|
16
|
+
export const InternalSourceProperties = t.object({
|
|
17
|
+
id: t.string
|
|
18
|
+
});
|
|
19
|
+
export const InternalSourceMetadata = t.object({
|
|
20
|
+
properties: InternalSourceProperties,
|
|
21
|
+
type: t.literal(SourceType.Internal)
|
|
22
|
+
});
|
|
23
|
+
export const AzureDevopsSourceProperties = t.object({
|
|
24
|
+
organization: t.string,
|
|
25
|
+
project: t.string,
|
|
26
|
+
repo: t.string
|
|
27
|
+
});
|
|
28
|
+
export const AzureDevopsSourceMetadata = t.object({
|
|
29
|
+
properties: AzureDevopsSourceProperties,
|
|
30
|
+
type: t.literal(SourceType.AzureDevops)
|
|
31
|
+
});
|
|
32
|
+
export const SourceMetadata = GitHubSourceMetadata.or(InternalSourceMetadata).or(AzureDevopsSourceMetadata);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This error class is designed to give consumers of Journey Micro
|
|
3
|
+
* a consistent way of "throwing" errors. Specifically, these errors
|
|
4
|
+
* will give clients to Journey Micro implementations two things:
|
|
5
|
+
*
|
|
6
|
+
* 1. An consistent, static error code by which to easily classify errors
|
|
7
|
+
* 2. An error message intended for humans
|
|
8
|
+
*
|
|
9
|
+
* Errors will usually assume that there is some client side error and default to 400 for
|
|
10
|
+
* a rest-like response. This can be changed however to more accurately, in restful terms,
|
|
11
|
+
* indicate what went wrong.
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare enum ErrorSeverity {
|
|
15
|
+
ERROR = "error",
|
|
16
|
+
INFO = "info",
|
|
17
|
+
WARNING = "warning"
|
|
18
|
+
}
|
|
19
|
+
export type ErrorData = {
|
|
20
|
+
code: string;
|
|
21
|
+
description: string;
|
|
22
|
+
details?: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
origin?: string;
|
|
25
|
+
severity?: ErrorSeverity;
|
|
26
|
+
stack?: string;
|
|
27
|
+
status?: number;
|
|
28
|
+
trace_id?: string;
|
|
29
|
+
};
|
|
30
|
+
export declare class JourneyError extends Error {
|
|
31
|
+
errorData: ErrorData;
|
|
32
|
+
is_journey_error: boolean;
|
|
33
|
+
constructor(data: ErrorData);
|
|
34
|
+
setTraceId(id: string): void;
|
|
35
|
+
toJSON(): ErrorData;
|
|
36
|
+
toString(): string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export declare class ValidationError extends JourneyError {
|
|
39
|
+
static CODE: string;
|
|
40
|
+
constructor(errors: any);
|
|
41
|
+
}
|
|
42
|
+
export declare class AuthorizationError extends JourneyError {
|
|
43
|
+
static CODE: string;
|
|
44
|
+
constructor(errors: any);
|
|
45
|
+
}
|
|
46
|
+
export declare class InternalServerError extends JourneyError {
|
|
47
|
+
static CODE: string;
|
|
48
|
+
constructor(err: Error);
|
|
49
|
+
}
|
|
50
|
+
export declare class ResourceNotFound extends JourneyError {
|
|
51
|
+
static CODE: string;
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use the (resource, id) constructor instead.
|
|
54
|
+
* @param id
|
|
55
|
+
*/
|
|
56
|
+
constructor(id: string);
|
|
57
|
+
constructor(resource: string, id: string);
|
|
58
|
+
}
|
|
59
|
+
export declare class ResourceConflict extends JourneyError {
|
|
60
|
+
static CODE: string;
|
|
61
|
+
constructor(details: string);
|
|
62
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
/**
|
|
4
|
+
* This error class is designed to give consumers of Journey Micro
|
|
5
|
+
* a consistent way of "throwing" errors. Specifically, these errors
|
|
6
|
+
* will give clients to Journey Micro implementations two things:
|
|
7
|
+
*
|
|
8
|
+
* 1. An consistent, static error code by which to easily classify errors
|
|
9
|
+
* 2. An error message intended for humans
|
|
10
|
+
*
|
|
11
|
+
* Errors will usually assume that there is some client side error and default to 400 for
|
|
12
|
+
* a rest-like response. This can be changed however to more accurately, in restful terms,
|
|
13
|
+
* indicate what went wrong.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export var ErrorSeverity;
|
|
17
|
+
(function (ErrorSeverity) {
|
|
18
|
+
ErrorSeverity["ERROR"] = "error";
|
|
19
|
+
ErrorSeverity["INFO"] = "info";
|
|
20
|
+
ErrorSeverity["WARNING"] = "warning";
|
|
21
|
+
})(ErrorSeverity || (ErrorSeverity = {}));
|
|
22
|
+
export class JourneyError extends Error {
|
|
23
|
+
errorData;
|
|
24
|
+
is_journey_error = true;
|
|
25
|
+
constructor(data) {
|
|
26
|
+
super(`[${data.code}] ${data.description}\n ${data.details}`);
|
|
27
|
+
this.errorData = data;
|
|
28
|
+
if (data.stack) {
|
|
29
|
+
this.stack = data.stack;
|
|
30
|
+
}
|
|
31
|
+
this.name = data.name || this.constructor.name;
|
|
32
|
+
this.errorData.name = this.name;
|
|
33
|
+
}
|
|
34
|
+
setTraceId(id) {
|
|
35
|
+
this.errorData.trace_id = id;
|
|
36
|
+
}
|
|
37
|
+
toJSON() {
|
|
38
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
39
|
+
return this.errorData;
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
code: this.errorData.code,
|
|
43
|
+
description: this.errorData.description,
|
|
44
|
+
details: this.errorData.details,
|
|
45
|
+
name: this.errorData.name,
|
|
46
|
+
origin: this.errorData.origin,
|
|
47
|
+
severity: this.errorData.severity,
|
|
48
|
+
status: this.errorData.status,
|
|
49
|
+
trace_id: this.errorData.trace_id
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
toString() {
|
|
53
|
+
return this.stack;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class ValidationError extends JourneyError {
|
|
57
|
+
static CODE = 'VALIDATION_ERROR';
|
|
58
|
+
constructor(errors) {
|
|
59
|
+
super({
|
|
60
|
+
code: ValidationError.CODE,
|
|
61
|
+
description: 'Validation failed',
|
|
62
|
+
details: JSON.stringify(errors),
|
|
63
|
+
status: 400
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class AuthorizationError extends JourneyError {
|
|
68
|
+
static CODE = 'AUTHORIZATION';
|
|
69
|
+
constructor(errors) {
|
|
70
|
+
super({
|
|
71
|
+
code: AuthorizationError.CODE,
|
|
72
|
+
description: 'Authorization failed',
|
|
73
|
+
details: errors,
|
|
74
|
+
status: 401
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class InternalServerError extends JourneyError {
|
|
79
|
+
static CODE = 'INTERNAL_SERVER_ERROR';
|
|
80
|
+
constructor(err) {
|
|
81
|
+
super({
|
|
82
|
+
code: InternalServerError.CODE,
|
|
83
|
+
description: 'Something went wrong',
|
|
84
|
+
details: err.message,
|
|
85
|
+
severity: ErrorSeverity.ERROR,
|
|
86
|
+
stack: process.env.NODE_ENV === 'production' ? undefined : err.stack,
|
|
87
|
+
status: 500
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export class ResourceNotFound extends JourneyError {
|
|
92
|
+
static CODE = 'RESOURCE_NOT_FOUND';
|
|
93
|
+
constructor(resource, id) {
|
|
94
|
+
const combinedId = id ? `${resource}/${id}` : resource;
|
|
95
|
+
super({
|
|
96
|
+
code: ResourceNotFound.CODE,
|
|
97
|
+
description: 'The requested resource does not exist on this server',
|
|
98
|
+
details: `The resource ${combinedId} does not exist on this server`,
|
|
99
|
+
severity: ErrorSeverity.INFO,
|
|
100
|
+
status: 404
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class ResourceConflict extends JourneyError {
|
|
105
|
+
static CODE = 'RESOURCE_CONFLICT';
|
|
106
|
+
constructor(details) {
|
|
107
|
+
super({
|
|
108
|
+
code: ResourceConflict.CODE,
|
|
109
|
+
description: 'The specified resource already exists on this server',
|
|
110
|
+
details,
|
|
111
|
+
severity: ErrorSeverity.INFO,
|
|
112
|
+
status: 409
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ErrorData, JourneyError } from './errors.js';
|
|
2
|
+
export declare const isJourneyError: (err: any) => err is JourneyError;
|
|
3
|
+
export declare const getErrorData: (err: Error | any) => ErrorData | undefined;
|
|
4
|
+
export declare const matchesErrorCode: (err: Error | any, code: string) => boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { JourneyError } from './errors.js';
|
|
3
|
+
export const isJourneyError = (err) => {
|
|
4
|
+
const matches = err instanceof JourneyError || err.is_journey_error;
|
|
5
|
+
return Boolean(matches);
|
|
6
|
+
};
|
|
7
|
+
export const getErrorData = (err) => {
|
|
8
|
+
if (!isJourneyError(err)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return err.toJSON();
|
|
12
|
+
};
|
|
13
|
+
export const matchesErrorCode = (err, code) => {
|
|
14
|
+
if (isJourneyError(err)) {
|
|
15
|
+
return err.errorData.code === code;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/* eslint-disable unicorn/text-encoding-identifier-case */
|
|
3
|
+
import * as bson from 'bson';
|
|
4
|
+
import * as defs from './definitions.js';
|
|
5
|
+
export const JSONCodec = {
|
|
6
|
+
decode(data) {
|
|
7
|
+
let raw;
|
|
8
|
+
if (data instanceof ArrayBuffer) {
|
|
9
|
+
const decoder = new TextDecoder('utf-8');
|
|
10
|
+
raw = decoder.decode(data);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
raw = data?.toString();
|
|
14
|
+
}
|
|
15
|
+
return JSON.parse(raw);
|
|
16
|
+
},
|
|
17
|
+
encode: (data) => JSON.stringify(data)
|
|
18
|
+
};
|
|
19
|
+
export const BSONCodec = {
|
|
20
|
+
decode(data) {
|
|
21
|
+
return bson.deserialize(data, {
|
|
22
|
+
promoteBuffers: true
|
|
23
|
+
});
|
|
24
|
+
},
|
|
25
|
+
encode(data) {
|
|
26
|
+
return bson.serialize(data, {
|
|
27
|
+
ignoreUndefined: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const DEFAULT_CODECS = {
|
|
32
|
+
[defs.ContentType.BSON]: BSONCodec,
|
|
33
|
+
[defs.ContentType.JSON]: JSONCodec
|
|
34
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
import * as micro_errors from '../errors/index.js';
|
|
4
|
+
import * as codecs from './codecs.js';
|
|
5
|
+
import * as defs from './definitions.js';
|
|
6
|
+
import * as errors from './errors.js';
|
|
7
|
+
export const decodeResponse = async (response, meta) => {
|
|
8
|
+
const content_type = response.headers.get(defs.Header.ContentType) || defs.ContentType.JSON;
|
|
9
|
+
// extract the first part of Content-Type - i.e "[application/json]; charset-utf8"
|
|
10
|
+
const codec = codecs.DEFAULT_CODECS[content_type.replace(/(?!<.*);.*/, '')];
|
|
11
|
+
if (!codec) {
|
|
12
|
+
const raw = await response.text();
|
|
13
|
+
throw new errors.UnparsableServiceResponse(`${meta.method} ${meta.url}`, response.status, raw);
|
|
14
|
+
}
|
|
15
|
+
return codec.decode(await response.arrayBuffer());
|
|
16
|
+
};
|
|
17
|
+
export const decodeServiceResponse = async (response, meta) => {
|
|
18
|
+
const { data, error } = await decodeResponse(response, meta);
|
|
19
|
+
if (data) {
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
if (error) {
|
|
23
|
+
throw new micro_errors.JourneyError(error);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Not a JSON response, meaning it's not a standard response or error produced by journey-micro.
|
|
27
|
+
* This typically means something like a 404 or a 503 (gateway error).
|
|
28
|
+
* The body is usually meaningless in these cases.
|
|
29
|
+
* 3xx responses are also unexpected here.
|
|
30
|
+
*/
|
|
31
|
+
if (response.status >= 300) {
|
|
32
|
+
throw new errors.UnparsableServiceResponse(`${meta.method} ${meta.url}`, response.status);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import type * as stream from 'node:stream/web';
|
|
4
|
+
import * as streaming from './streaming.js';
|
|
5
|
+
export type Codec<T = any> = {
|
|
6
|
+
decode: (data: ArrayBuffer | Buffer) => T;
|
|
7
|
+
encode: (data: T) => Buffer | string;
|
|
8
|
+
};
|
|
9
|
+
export type Codecs = Record<string, Codec>;
|
|
10
|
+
export type RetryStrategy = (attempt: number) => number;
|
|
11
|
+
export declare enum Header {
|
|
12
|
+
Accept = "Accept",
|
|
13
|
+
Authorization = "Authorization",
|
|
14
|
+
ContentType = "Content-Type",
|
|
15
|
+
UserAgent = "User-Agent"
|
|
16
|
+
}
|
|
17
|
+
export type Headers = Partial<Record<Header, string>> & Record<string, string>;
|
|
18
|
+
export type HeaderCollector = (() => Headers) | (() => Promise<Headers>);
|
|
19
|
+
export type RequestHeaders = HeaderCollector | Headers;
|
|
20
|
+
export declare enum ContentType {
|
|
21
|
+
BSON = "application/bson",
|
|
22
|
+
BSONStream = "application/vnd.journeyapps.bson-stream+header",
|
|
23
|
+
HeaderStream = "application/vnd.journeyapps.raw+header",
|
|
24
|
+
JSON = "application/json"
|
|
25
|
+
}
|
|
26
|
+
export declare enum METHOD {
|
|
27
|
+
DELETE = "DELETE",
|
|
28
|
+
GET = "GET",
|
|
29
|
+
PATCH = "PATCH",
|
|
30
|
+
POST = "POST",
|
|
31
|
+
PUT = "PUT"
|
|
32
|
+
}
|
|
33
|
+
export type StringMethod = 'delete' | 'get' | 'patch' | 'post' | 'put';
|
|
34
|
+
type ResponseHeaders = {
|
|
35
|
+
get(key: string): null | string;
|
|
36
|
+
};
|
|
37
|
+
export type TResponse = {
|
|
38
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
39
|
+
body: any;
|
|
40
|
+
headers: ResponseHeaders;
|
|
41
|
+
status: number;
|
|
42
|
+
text: () => Promise<string>;
|
|
43
|
+
};
|
|
44
|
+
export type RequestMetadata = {
|
|
45
|
+
method: string;
|
|
46
|
+
url: string;
|
|
47
|
+
};
|
|
48
|
+
export type ResponseDecoder<R extends TResponse = TResponse> = (response: R, request_context: RequestMetadata) => Promise<any> | any;
|
|
49
|
+
export type CommonRequestParams<R extends TResponse = TResponse> = {
|
|
50
|
+
decoder?: ResponseDecoder<R>;
|
|
51
|
+
headers?: RequestHeaders;
|
|
52
|
+
/**
|
|
53
|
+
* Maximum amount of time between two consecutive bytes read on a stream. Only applies to
|
|
54
|
+
* streamed responses.
|
|
55
|
+
*
|
|
56
|
+
* Set to 0 to disable
|
|
57
|
+
*
|
|
58
|
+
* @default 20000
|
|
59
|
+
*/
|
|
60
|
+
read_timeout?: number;
|
|
61
|
+
retry_attempts?: number;
|
|
62
|
+
retry_strategy?: RetryStrategy;
|
|
63
|
+
/**
|
|
64
|
+
* Maximum amount of time allowed to receive a response to a request
|
|
65
|
+
*
|
|
66
|
+
* Set to 0 to disable
|
|
67
|
+
*
|
|
68
|
+
* @default 60000
|
|
69
|
+
*/
|
|
70
|
+
timeout?: number;
|
|
71
|
+
};
|
|
72
|
+
export type RequestParams<R extends TResponse, T> = CommonRequestParams<R> & {
|
|
73
|
+
body?: T | streaming.StreamPayload<any, any, any>;
|
|
74
|
+
method: METHOD | StringMethod;
|
|
75
|
+
retryable?: boolean;
|
|
76
|
+
};
|
|
77
|
+
export type NetworkClientParams<R extends TResponse = TResponse> = CommonRequestParams<R> & {
|
|
78
|
+
codecs?: Codecs;
|
|
79
|
+
user_agent?: string;
|
|
80
|
+
};
|
|
81
|
+
export type NetworkResponse<T extends TResponse, O = any> = {
|
|
82
|
+
/**
|
|
83
|
+
* Decode the response using the configured default decoder
|
|
84
|
+
*/
|
|
85
|
+
decode: <T = O>() => Promise<T>;
|
|
86
|
+
response: T;
|
|
87
|
+
stream: () => Promise<stream.ReadableStream<Buffer>>;
|
|
88
|
+
};
|
|
89
|
+
export type NetworkClient<I = any, O extends NetworkResponse<any> = NetworkResponse<any>> = {
|
|
90
|
+
augment: <C extends NetworkClient<I, O>>(options: Partial<NetworkClientParams>) => C;
|
|
91
|
+
request: (url: string, params: RequestParams<ExtractNativeResponseFromNetworkResponse<O>, I>) => Promise<O>;
|
|
92
|
+
};
|
|
93
|
+
export type ExtractNetworkResponseFromNetworkClient<T extends NetworkClient> = T extends NetworkClient<any, infer R> ? R : never;
|
|
94
|
+
export type ExtractNativeResponseFromNetworkResponse<T extends NetworkResponse<any>> = T extends NetworkResponse<infer R> ? R : never;
|
|
95
|
+
export type ExtractNativeResponse<C extends NetworkClient> = ExtractNativeResponseFromNetworkResponse<ExtractNetworkResponseFromNetworkClient<C>>;
|
|
96
|
+
export type ExtractBody<C extends NetworkClient> = Exclude<ExtractNativeResponse<C>['body'], null>;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var Header;
|
|
2
|
+
(function (Header) {
|
|
3
|
+
Header["Accept"] = "Accept";
|
|
4
|
+
Header["Authorization"] = "Authorization";
|
|
5
|
+
Header["ContentType"] = "Content-Type";
|
|
6
|
+
Header["UserAgent"] = "User-Agent";
|
|
7
|
+
})(Header || (Header = {}));
|
|
8
|
+
export var ContentType;
|
|
9
|
+
(function (ContentType) {
|
|
10
|
+
ContentType["BSON"] = "application/bson";
|
|
11
|
+
ContentType["BSONStream"] = "application/vnd.journeyapps.bson-stream+header";
|
|
12
|
+
ContentType["HeaderStream"] = "application/vnd.journeyapps.raw+header";
|
|
13
|
+
ContentType["JSON"] = "application/json";
|
|
14
|
+
})(ContentType || (ContentType = {}));
|
|
15
|
+
export var METHOD;
|
|
16
|
+
(function (METHOD) {
|
|
17
|
+
METHOD["DELETE"] = "DELETE";
|
|
18
|
+
METHOD["GET"] = "GET";
|
|
19
|
+
METHOD["PATCH"] = "PATCH";
|
|
20
|
+
METHOD["POST"] = "POST";
|
|
21
|
+
METHOD["PUT"] = "PUT";
|
|
22
|
+
})(METHOD || (METHOD = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as micro_errors from '../errors/index.js';
|
|
2
|
+
export declare class TimeoutError extends Error {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare class UnparsableServiceResponse extends micro_errors.JourneyError {
|
|
6
|
+
constructor(endpoint: string, status: number, raw?: string);
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import * as micro_errors from '../errors/index.js';
|
|
3
|
+
export class TimeoutError extends Error {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.message = 'Request timed out';
|
|
7
|
+
this.name = 'TimeoutError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class UnparsableServiceResponse extends micro_errors.JourneyError {
|
|
11
|
+
constructor(endpoint, status, raw) {
|
|
12
|
+
super({
|
|
13
|
+
code: 'UNPARSABLE_SERVICE_RESPONSE',
|
|
14
|
+
description: 'Could not parse service response',
|
|
15
|
+
details: `${endpoint}\n${raw || 'unparseable'}`,
|
|
16
|
+
status
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import * as http from 'node:http';
|
|
3
|
+
import * as defs from './definitions.js';
|
|
4
|
+
export type NodeResponse = Omit<defs.TResponse, 'body'> & {
|
|
5
|
+
body: http.IncomingMessage;
|
|
6
|
+
};
|
|
7
|
+
export type NodeNetworkResponse<O = any> = defs.NetworkResponse<NodeResponse, O>;
|
|
8
|
+
export type NodeNetworkClient = defs.NetworkClient<any, NodeNetworkResponse>;
|
|
9
|
+
export declare const createNodeNetworkClient: (options?: defs.NetworkClientParams<NodeResponse>) => NodeNetworkClient;
|