powersync 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +14 -14
  2. package/dist/commands/init.d.ts +0 -1
  3. package/dist/commands/init.js +11 -8
  4. package/dist/commands/instance/sync-rules/generate-schema.js +6 -6
  5. package/dist/constants.d.ts +2 -5
  6. package/dist/constants.js +4 -2
  7. package/dist/service/accounts.client.js +11129 -25
  8. package/dist/service/powersync.client.js +37453 -113
  9. package/dist/service/types.js +1 -1
  10. package/dist/service/utils.js +6 -6
  11. package/dist/utils.js +5 -7
  12. package/oclif.manifest.json +1 -1
  13. package/package.json +28 -20
  14. package/dist/powersync-sdk/accounts/api.d.ts +0 -717
  15. package/dist/powersync-sdk/accounts/api.js +0 -182
  16. package/dist/powersync-sdk/accounts/client.d.ts +0 -1096
  17. package/dist/powersync-sdk/accounts/client.js +0 -124
  18. package/dist/powersync-sdk/accounts/codecs.d.ts +0 -32
  19. package/dist/powersync-sdk/accounts/codecs.js +0 -93
  20. package/dist/powersync-sdk/accounts/index.d.ts +0 -4
  21. package/dist/powersync-sdk/accounts/index.js +0 -4
  22. package/dist/powersync-sdk/accounts/models.d.ts +0 -260
  23. package/dist/powersync-sdk/accounts/models.js +0 -96
  24. package/dist/powersync-sdk/accounts/routes.d.ts +0 -44
  25. package/dist/powersync-sdk/accounts/routes.js +0 -45
  26. package/dist/powersync-sdk/accounts/source.d.ts +0 -76
  27. package/dist/powersync-sdk/accounts/source.js +0 -32
  28. package/dist/powersync-sdk/errors/errors.d.ts +0 -62
  29. package/dist/powersync-sdk/errors/errors.js +0 -115
  30. package/dist/powersync-sdk/errors/index.d.ts +0 -2
  31. package/dist/powersync-sdk/errors/index.js +0 -2
  32. package/dist/powersync-sdk/errors/utils.d.ts +0 -4
  33. package/dist/powersync-sdk/errors/utils.js +0 -18
  34. package/dist/powersync-sdk/fetch-clients/codecs.d.ts +0 -4
  35. package/dist/powersync-sdk/fetch-clients/codecs.js +0 -34
  36. package/dist/powersync-sdk/fetch-clients/decoders.d.ts +0 -3
  37. package/dist/powersync-sdk/fetch-clients/decoders.js +0 -35
  38. package/dist/powersync-sdk/fetch-clients/definitions.d.ts +0 -97
  39. package/dist/powersync-sdk/fetch-clients/definitions.js +0 -22
  40. package/dist/powersync-sdk/fetch-clients/errors.d.ts +0 -7
  41. package/dist/powersync-sdk/fetch-clients/errors.js +0 -19
  42. package/dist/powersync-sdk/fetch-clients/index.d.ts +0 -5
  43. package/dist/powersync-sdk/fetch-clients/index.js +0 -5
  44. package/dist/powersync-sdk/fetch-clients/node-client.d.ts +0 -9
  45. package/dist/powersync-sdk/fetch-clients/node-client.js +0 -107
  46. package/dist/powersync-sdk/fetch-clients/request.d.ts +0 -11
  47. package/dist/powersync-sdk/fetch-clients/request.js +0 -138
  48. package/dist/powersync-sdk/fetch-clients/streaming.d.ts +0 -65
  49. package/dist/powersync-sdk/fetch-clients/streaming.js +0 -99
  50. package/dist/powersync-sdk/fetch-clients/utils.d.ts +0 -13
  51. package/dist/powersync-sdk/fetch-clients/utils.js +0 -43
  52. package/dist/powersync-sdk/fetch-clients/web-client.d.ts +0 -14
  53. package/dist/powersync-sdk/fetch-clients/web-client.js +0 -56
  54. package/dist/powersync-sdk/json/index.d.ts +0 -4
  55. package/dist/powersync-sdk/json/index.js +0 -3
  56. package/dist/powersync-sdk/json/json.d.ts +0 -5
  57. package/dist/powersync-sdk/json/json.js +0 -35
  58. package/dist/powersync-sdk/json/json_container.d.ts +0 -18
  59. package/dist/powersync-sdk/json/json_container.js +0 -28
  60. package/dist/powersync-sdk/json/json_stringify.d.ts +0 -36
  61. package/dist/powersync-sdk/json/json_stringify.js +0 -162
  62. package/dist/powersync-sdk/powersync/client.d.ts +0 -449
  63. package/dist/powersync-sdk/powersync/client.js +0 -53
  64. package/dist/powersync-sdk/powersync/config/HostedConfig.d.ts +0 -327
  65. package/dist/powersync-sdk/powersync/config/HostedConfig.js +0 -92
  66. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.d.ts +0 -211
  67. package/dist/powersync-sdk/powersync/config/PowerSyncConfig.js +0 -97
  68. package/dist/powersync-sdk/powersync/config/normalize.d.ts +0 -32
  69. package/dist/powersync-sdk/powersync/config/normalize.js +0 -85
  70. package/dist/powersync-sdk/powersync/definitions.d.ts +0 -149
  71. package/dist/powersync-sdk/powersync/definitions.js +0 -97
  72. package/dist/powersync-sdk/powersync/index.d.ts +0 -8
  73. package/dist/powersync-sdk/powersync/index.js +0 -8
  74. package/dist/powersync-sdk/powersync/internal_routes.d.ts +0 -247
  75. package/dist/powersync-sdk/powersync/internal_routes.js +0 -69
  76. package/dist/powersync-sdk/powersync/routes.d.ts +0 -779
  77. package/dist/powersync-sdk/powersync/routes.js +0 -191
  78. package/dist/powersync-sdk/sdk-clients/endpoints.d.ts +0 -31
  79. package/dist/powersync-sdk/sdk-clients/endpoints.js +0 -48
  80. package/dist/powersync-sdk/sdk-clients/index.d.ts +0 -3
  81. package/dist/powersync-sdk/sdk-clients/index.js +0 -3
  82. package/dist/powersync-sdk/sdk-clients/pagination.d.ts +0 -14
  83. package/dist/powersync-sdk/sdk-clients/pagination.js +0 -21
  84. package/dist/powersync-sdk/sdk-clients/sdk-client.d.ts +0 -17
  85. package/dist/powersync-sdk/sdk-clients/sdk-client.js +0 -30
  86. package/dist/powersync-sdk/streaming/bson/buffer-array.d.ts +0 -31
  87. package/dist/powersync-sdk/streaming/bson/buffer-array.js +0 -79
  88. package/dist/powersync-sdk/streaming/bson/constants.d.ts +0 -2
  89. package/dist/powersync-sdk/streaming/bson/constants.js +0 -1
  90. package/dist/powersync-sdk/streaming/bson/decoder.d.ts +0 -10
  91. package/dist/powersync-sdk/streaming/bson/decoder.js +0 -62
  92. package/dist/powersync-sdk/streaming/bson/encoder.d.ts +0 -10
  93. package/dist/powersync-sdk/streaming/bson/encoder.js +0 -23
  94. package/dist/powersync-sdk/streaming/bson/header.d.ts +0 -11
  95. package/dist/powersync-sdk/streaming/bson/header.js +0 -52
  96. package/dist/powersync-sdk/streaming/bson/index.d.ts +0 -5
  97. package/dist/powersync-sdk/streaming/bson/index.js +0 -5
  98. package/dist/powersync-sdk/streaming/core/backpressure.d.ts +0 -15
  99. package/dist/powersync-sdk/streaming/core/backpressure.js +0 -34
  100. package/dist/powersync-sdk/streaming/core/cross-stream.d.ts +0 -6
  101. package/dist/powersync-sdk/streaming/core/cross-stream.js +0 -17
  102. package/dist/powersync-sdk/streaming/core/index.d.ts +0 -4
  103. package/dist/powersync-sdk/streaming/core/index.js +0 -4
  104. package/dist/powersync-sdk/streaming/core/node-utils.d.ts +0 -7
  105. package/dist/powersync-sdk/streaming/core/node-utils.js +0 -11
  106. package/dist/powersync-sdk/streaming/core/transformers.d.ts +0 -41
  107. package/dist/powersync-sdk/streaming/core/transformers.js +0 -70
  108. package/dist/powersync-sdk/streaming/core/utils.d.ts +0 -36
  109. package/dist/powersync-sdk/streaming/core/utils.js +0 -66
  110. package/dist/powersync-sdk/streaming/index.d.ts +0 -3
  111. package/dist/powersync-sdk/streaming/index.js +0 -3
  112. package/dist/powersync-sdk/streaming/web.d.ts +0 -4
  113. package/dist/powersync-sdk/streaming/web.js +0 -4
  114. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.d.ts +0 -2
  115. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binaryreader.js +0 -36
  116. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.d.ts +0 -2
  117. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/binarywriter.js +0 -58
  118. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.d.ts +0 -18
  119. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometry.js +0 -348
  120. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.d.ts +0 -11
  121. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/geometrycollection.js +0 -118
  122. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.d.ts +0 -11
  123. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/linestring.js +0 -131
  124. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.d.ts +0 -11
  125. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multilinestring.js +0 -134
  126. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.d.ts +0 -11
  127. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipoint.js +0 -122
  128. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.d.ts +0 -11
  129. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/multipolygon.js +0 -158
  130. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.d.ts +0 -14
  131. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/point.js +0 -165
  132. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.d.ts +0 -11
  133. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/polygon.js +0 -207
  134. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.d.ts +0 -30
  135. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/types.js +0 -29
  136. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.d.ts +0 -2
  137. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wktparser.js +0 -111
  138. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.d.ts +0 -9
  139. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/wkx.js +0 -9
  140. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.d.ts +0 -5
  141. package/dist/powersync-sdk/sync-rules/@syncpoint/wkx/zigzag.js +0 -9
  142. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.d.ts +0 -12
  143. package/dist/powersync-sdk/sync-rules/DartSchemaGenerator.js +0 -35
  144. package/dist/powersync-sdk/sync-rules/ExpressionType.d.ts +0 -33
  145. package/dist/powersync-sdk/sync-rules/ExpressionType.js +0 -62
  146. package/dist/powersync-sdk/sync-rules/IdSequence.d.ts +0 -4
  147. package/dist/powersync-sdk/sync-rules/IdSequence.js +0 -7
  148. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.d.ts +0 -12
  149. package/dist/powersync-sdk/sync-rules/JsSchemaGenerator.js +0 -38
  150. package/dist/powersync-sdk/sync-rules/SchemaGenerator.d.ts +0 -14
  151. package/dist/powersync-sdk/sync-rules/SchemaGenerator.js +0 -24
  152. package/dist/powersync-sdk/sync-rules/SourceTableInterface.d.ts +0 -5
  153. package/dist/powersync-sdk/sync-rules/SourceTableInterface.js +0 -1
  154. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.d.ts +0 -37
  155. package/dist/powersync-sdk/sync-rules/SqlBucketDescriptor.js +0 -116
  156. package/dist/powersync-sdk/sync-rules/SqlDataQuery.d.ts +0 -39
  157. package/dist/powersync-sdk/sync-rules/SqlDataQuery.js +0 -245
  158. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.d.ts +0 -43
  159. package/dist/powersync-sdk/sync-rules/SqlParameterQuery.js +0 -254
  160. package/dist/powersync-sdk/sync-rules/SqlSyncRules.d.ts +0 -52
  161. package/dist/powersync-sdk/sync-rules/SqlSyncRules.js +0 -252
  162. package/dist/powersync-sdk/sync-rules/StaticSchema.d.ts +0 -26
  163. package/dist/powersync-sdk/sync-rules/StaticSchema.js +0 -71
  164. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.d.ts +0 -24
  165. package/dist/powersync-sdk/sync-rules/StaticSqlParameterQuery.js +0 -71
  166. package/dist/powersync-sdk/sync-rules/TablePattern.d.ts +0 -17
  167. package/dist/powersync-sdk/sync-rules/TablePattern.js +0 -56
  168. package/dist/powersync-sdk/sync-rules/TableQuerySchema.d.ts +0 -9
  169. package/dist/powersync-sdk/sync-rules/TableQuerySchema.js +0 -41
  170. package/dist/powersync-sdk/sync-rules/errors.d.ts +0 -22
  171. package/dist/powersync-sdk/sync-rules/errors.js +0 -60
  172. package/dist/powersync-sdk/sync-rules/generators.d.ts +0 -6
  173. package/dist/powersync-sdk/sync-rules/generators.js +0 -6
  174. package/dist/powersync-sdk/sync-rules/index.d.ts +0 -17
  175. package/dist/powersync-sdk/sync-rules/index.js +0 -17
  176. package/dist/powersync-sdk/sync-rules/json_schema.d.ts +0 -3
  177. package/dist/powersync-sdk/sync-rules/json_schema.js +0 -50
  178. package/dist/powersync-sdk/sync-rules/sql_filters.d.ts +0 -91
  179. package/dist/powersync-sdk/sync-rules/sql_filters.js +0 -491
  180. package/dist/powersync-sdk/sync-rules/sql_functions.d.ts +0 -53
  181. package/dist/powersync-sdk/sync-rules/sql_functions.js +0 -755
  182. package/dist/powersync-sdk/sync-rules/sql_support.d.ts +0 -22
  183. package/dist/powersync-sdk/sync-rules/sql_support.js +0 -208
  184. package/dist/powersync-sdk/sync-rules/types.d.ts +0 -174
  185. package/dist/powersync-sdk/sync-rules/types.js +0 -9
  186. package/dist/powersync-sdk/sync-rules/utils.d.ts +0 -45
  187. package/dist/powersync-sdk/sync-rules/utils.js +0 -163
  188. package/dist/service/accounts.client.d.ts +0 -26
  189. package/dist/service/powersync.client.d.ts +0 -269
  190. package/dist/service/types.d.ts +0 -69
  191. package/dist/service/utils.d.ts +0 -5
@@ -1,45 +0,0 @@
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 = {}));
@@ -1,76 +0,0 @@
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>;
@@ -1,32 +0,0 @@
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);
@@ -1,62 +0,0 @@
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
- }
@@ -1,115 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export * from './errors.js';
2
- export * from './utils.js';
@@ -1,2 +0,0 @@
1
- export * from './errors.js';
2
- export * from './utils.js';
@@ -1,4 +0,0 @@
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;
@@ -1,18 +0,0 @@
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
- };
@@ -1,4 +0,0 @@
1
- import * as defs from './definitions.js';
2
- export declare const JSONCodec: defs.Codec;
3
- export declare const BSONCodec: defs.Codec;
4
- export declare const DEFAULT_CODECS: defs.Codecs;
@@ -1,34 +0,0 @@
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
- };
@@ -1,3 +0,0 @@
1
- import * as defs from './definitions.js';
2
- export declare const decodeResponse: defs.ResponseDecoder;
3
- export declare const decodeServiceResponse: defs.ResponseDecoder;
@@ -1,35 +0,0 @@
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
- };
@@ -1,97 +0,0 @@
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 {};
@@ -1,22 +0,0 @@
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 = {}));
@@ -1,7 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- export * from '../streaming/index.js';
2
- export * from './decoders.js';
3
- export * from './request.js';
4
- export * from './errors.js';
5
- export * from './codecs.js';
@@ -1,5 +0,0 @@
1
- export * from '../streaming/index.js';
2
- export * from './decoders.js';
3
- export * from './request.js';
4
- export * from './errors.js';
5
- export * from './codecs.js';
@@ -1,9 +0,0 @@
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;