@worknice/js-sdk 0.0.1

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 (112) hide show
  1. package/LICENSE +16 -0
  2. package/README.md +5 -0
  3. package/dist/_types-DsB4q143.d.ts +127 -0
  4. package/dist/api/ApiError.d.ts +12 -0
  5. package/dist/api/ApiError.js +27 -0
  6. package/dist/api/ApiError.js.map +1 -0
  7. package/dist/api/_generated.d.ts +5040 -0
  8. package/dist/api/_generated.js +386 -0
  9. package/dist/api/_generated.js.map +1 -0
  10. package/dist/api/_types.d.ts +2 -0
  11. package/dist/api/_types.js +1 -0
  12. package/dist/api/_types.js.map +1 -0
  13. package/dist/api/assertNotNull.d.ts +5 -0
  14. package/dist/api/assertNotNull.js +14 -0
  15. package/dist/api/assertNotNull.js.map +1 -0
  16. package/dist/api/createApiOperation.d.ts +11 -0
  17. package/dist/api/createApiOperation.js +6 -0
  18. package/dist/api/createApiOperation.js.map +1 -0
  19. package/dist/api/createWorkniceClient.d.ts +2 -0
  20. package/dist/api/createWorkniceClient.js +101 -0
  21. package/dist/api/createWorkniceClient.js.map +1 -0
  22. package/dist/api/operations/activateIntegration.d.ts +22 -0
  23. package/dist/api/operations/activateIntegration.js +29 -0
  24. package/dist/api/operations/activateIntegration.js.map +1 -0
  25. package/dist/api/operations/createApiToken.d.ts +14 -0
  26. package/dist/api/operations/createApiToken.js +31 -0
  27. package/dist/api/operations/createApiToken.js.map +1 -0
  28. package/dist/api/operations/deleteApiToken.d.ts +10 -0
  29. package/dist/api/operations/deleteApiToken.js +21 -0
  30. package/dist/api/operations/deleteApiToken.js.map +1 -0
  31. package/dist/api/operations/getApiTokens.d.ts +14 -0
  32. package/dist/api/operations/getApiTokens.js +33 -0
  33. package/dist/api/operations/getApiTokens.js.map +1 -0
  34. package/dist/api/operations/initializeIntegration.d.ts +20 -0
  35. package/dist/api/operations/initializeIntegration.js +23 -0
  36. package/dist/api/operations/initializeIntegration.js.map +1 -0
  37. package/dist/employee-records/EQUALITY_CHECKS.d.ts +9 -0
  38. package/dist/employee-records/EQUALITY_CHECKS.js +100 -0
  39. package/dist/employee-records/EQUALITY_CHECKS.js.map +1 -0
  40. package/dist/employee-records/_types.d.ts +171 -0
  41. package/dist/employee-records/_types.js +1 -0
  42. package/dist/employee-records/_types.js.map +1 -0
  43. package/dist/employee-records/comparePersonDataTransferLines.d.ts +5 -0
  44. package/dist/employee-records/comparePersonDataTransferLines.js +338 -0
  45. package/dist/employee-records/comparePersonDataTransferLines.js.map +1 -0
  46. package/dist/employee-records/index.d.ts +16 -0
  47. package/dist/employee-records/index.js +25 -0
  48. package/dist/employee-records/index.js.map +1 -0
  49. package/dist/employee-records/mergePersonDataTransferLines.d.ts +5 -0
  50. package/dist/employee-records/mergePersonDataTransferLines.js +27 -0
  51. package/dist/employee-records/mergePersonDataTransferLines.js.map +1 -0
  52. package/dist/employee-records/validatePersonDataTransferLine.d.ts +5 -0
  53. package/dist/employee-records/validatePersonDataTransferLine.js +23 -0
  54. package/dist/employee-records/validatePersonDataTransferLine.js.map +1 -0
  55. package/dist/employee-records/validatePersonDataTransferLineBankAccounts.d.ts +5 -0
  56. package/dist/employee-records/validatePersonDataTransferLineBankAccounts.js +240 -0
  57. package/dist/employee-records/validatePersonDataTransferLineBankAccounts.js.map +1 -0
  58. package/dist/employee-records/validatePersonDataTransferLineEmergencyContacts.d.ts +5 -0
  59. package/dist/employee-records/validatePersonDataTransferLineEmergencyContacts.js +6 -0
  60. package/dist/employee-records/validatePersonDataTransferLineEmergencyContacts.js.map +1 -0
  61. package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.d.ts +5 -0
  62. package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.js +40 -0
  63. package/dist/employee-records/validatePersonDataTransferLinePersonalDetails.js.map +1 -0
  64. package/dist/employee-records/validatePersonDataTransferLinePostalAddress.d.ts +5 -0
  65. package/dist/employee-records/validatePersonDataTransferLinePostalAddress.js +39 -0
  66. package/dist/employee-records/validatePersonDataTransferLinePostalAddress.js.map +1 -0
  67. package/dist/employee-records/validatePersonDataTransferLineResidentialAddress.d.ts +5 -0
  68. package/dist/employee-records/validatePersonDataTransferLineResidentialAddress.js +39 -0
  69. package/dist/employee-records/validatePersonDataTransferLineResidentialAddress.js.map +1 -0
  70. package/dist/employee-records/validatePersonDataTransferLineSuperFunds.d.ts +5 -0
  71. package/dist/employee-records/validatePersonDataTransferLineSuperFunds.js +46 -0
  72. package/dist/employee-records/validatePersonDataTransferLineSuperFunds.js.map +1 -0
  73. package/dist/employee-records/validatePersonDataTransferLineTaxDetails.d.ts +5 -0
  74. package/dist/employee-records/validatePersonDataTransferLineTaxDetails.js +46 -0
  75. package/dist/employee-records/validatePersonDataTransferLineTaxDetails.js.map +1 -0
  76. package/dist/employee-records/validatePersonDataTransferLineTenure.d.ts +5 -0
  77. package/dist/employee-records/validatePersonDataTransferLineTenure.js +20 -0
  78. package/dist/employee-records/validatePersonDataTransferLineTenure.js.map +1 -0
  79. package/dist/helpers/_types.d.ts +17 -0
  80. package/dist/helpers/_types.js +1 -0
  81. package/dist/helpers/_types.js.map +1 -0
  82. package/dist/helpers/handleCreateIntegrationWebhook.d.ts +11 -0
  83. package/dist/helpers/handleCreateIntegrationWebhook.js +20 -0
  84. package/dist/helpers/handleCreateIntegrationWebhook.js.map +1 -0
  85. package/dist/helpers/handleGetAuthorizationUrlWebhook.d.ts +11 -0
  86. package/dist/helpers/handleGetAuthorizationUrlWebhook.js +19 -0
  87. package/dist/helpers/handleGetAuthorizationUrlWebhook.js.map +1 -0
  88. package/dist/helpers/handleRequestWithWorknice.d.ts +19 -0
  89. package/dist/helpers/handleRequestWithWorknice.js +46 -0
  90. package/dist/helpers/handleRequestWithWorknice.js.map +1 -0
  91. package/dist/helpers/index.d.ts +5 -0
  92. package/dist/helpers/index.js +5 -0
  93. package/dist/helpers/index.js.map +1 -0
  94. package/dist/index.d.ts +16 -0
  95. package/dist/index.js +12 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/utils/errorToString.d.ts +22 -0
  98. package/dist/utils/errorToString.js +28 -0
  99. package/dist/utils/errorToString.js.map +1 -0
  100. package/dist/utils/isAfter.d.ts +4 -0
  101. package/dist/utils/isAfter.js +5 -0
  102. package/dist/utils/isAfter.js.map +1 -0
  103. package/dist/utils/isSamePlainDate.d.ts +1 -0
  104. package/dist/utils/isSamePlainDate.js +5 -0
  105. package/dist/utils/isSamePlainDate.js.map +1 -0
  106. package/dist/utils/isValidPlainDate.d.ts +1 -0
  107. package/dist/utils/isValidPlainDate.js +5 -0
  108. package/dist/utils/isValidPlainDate.js.map +1 -0
  109. package/dist/utils/parsePlainDate.d.ts +1 -0
  110. package/dist/utils/parsePlainDate.js +5 -0
  111. package/dist/utils/parsePlainDate.js.map +1 -0
  112. package/package.json +71 -0
package/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ Copyright (c) 2024 Worknice
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
+ associated documentation files (the "Software"), to deal in the Software without restriction,
5
+ including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
+ sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial
10
+ portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
+ NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
15
+ OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # JS-SDK
2
+
3
+ ```bash
4
+ pnpm install @worknice/js-sdk currency.js
5
+ ```
@@ -0,0 +1,127 @@
1
+ import { Exact, Scalars, InputMaybe } from './api/_generated.js';
2
+
3
+ declare const createWorkniceClient: (clientConfig?: ClientConfig) => {
4
+ fetchFromApi: <Data extends object, Variables extends object>(query: string, variables?: Variables, fetchOptions?: FetchOptions) => Promise<SuccessfulQueryResult<Data>>;
5
+ /**
6
+ * Transitions an integration with an 'UNAUTHORIZED' or 'UNCONFIGURED'
7
+ * status to an 'ACTIVE' status. Optionally, the name of the integration can
8
+ * be set at the same time.
9
+ */
10
+ activateIntegration: (variables: Pick<Exact<{
11
+ id: Scalars["ID"]["input"];
12
+ name?: InputMaybe<Scalars["String"]["input"]>;
13
+ rename: Scalars["Boolean"]["input"];
14
+ }>, "id" | "name">, fetchOptions?: FetchOptions) => Promise<{
15
+ id: string;
16
+ } | {
17
+ id: string;
18
+ } | {
19
+ id: string;
20
+ } | {
21
+ id: string;
22
+ } | {
23
+ id: string;
24
+ }>;
25
+ /**
26
+ * Creates a new API token belonging to the current person.
27
+ */
28
+ createApiToken: (variables: Exact<{
29
+ name: Scalars["String"]["input"];
30
+ }>, fetchOptions?: FetchOptions) => Promise<{
31
+ token: string;
32
+ id: string;
33
+ name: string;
34
+ }>;
35
+ /**
36
+ * Permanently deletes an API token belonging to the current person.
37
+ */
38
+ deleteApiToken: (variables: Exact<{
39
+ tokenId: Scalars["ID"]["input"];
40
+ }>, fetchOptions?: FetchOptions) => Promise<boolean>;
41
+ /**
42
+ * Transitions an integration with an 'UNINITIALIZED' status to an 'UNAUTHORIZED' status.
43
+ */
44
+ initializeIntegration: (variables: Exact<{
45
+ id: Scalars["ID"]["input"];
46
+ }>, fetchOptions?: FetchOptions) => Promise<{
47
+ id: string;
48
+ } | {
49
+ id: string;
50
+ } | {
51
+ id: string;
52
+ } | {
53
+ id: string;
54
+ } | {
55
+ id: string;
56
+ }>;
57
+ /**
58
+ * Returns a list of API tokens belonging to the current person. This will not
59
+ * include the token values themselves as they are only available when the
60
+ * token is initially created.
61
+ *
62
+ * If there is no person associated with the session, a `NO_PERSON` error will
63
+ * be thrown.
64
+ */
65
+ getApiTokens: (variables: Exact<{
66
+ [key: string]: never;
67
+ }>, fetchOptions?: FetchOptions) => Promise<{
68
+ createdAt: string;
69
+ id: string;
70
+ name: string;
71
+ }[]>;
72
+ };
73
+
74
+ type SuccessfulQueryResult<Data extends object = object> = Readonly<{
75
+ data: Data;
76
+ }> | Readonly<{
77
+ data: Data;
78
+ errors: ReadonlyArray<GraphQLFormattedError>;
79
+ }>;
80
+ type FailedQueryResult = Readonly<{
81
+ data: null;
82
+ errors: ReadonlyArray<GraphQLFormattedError>;
83
+ }> | Readonly<{
84
+ errors: ReadonlyArray<GraphQLFormattedError>;
85
+ }>;
86
+ type QueryResult<Data extends object = object> = SuccessfulQueryResult<Data> | FailedQueryResult;
87
+ type FetchOptions = {
88
+ signal?: AbortSignal;
89
+ };
90
+ type ClientConfig = {
91
+ accessToken?: string;
92
+ apiUrl?: string;
93
+ };
94
+ type WorkniceClient = ReturnType<typeof createWorkniceClient>;
95
+ interface GraphQLFormattedError {
96
+ /**
97
+ * A short, human-readable summary of the problem that **SHOULD NOT** change
98
+ * from occurrence to occurrence of the problem, except for purposes of
99
+ * localization.
100
+ */
101
+ readonly message: string;
102
+ /**
103
+ * If an error can be associated to a particular point in the requested
104
+ * GraphQL document, it should contain a list of locations.
105
+ */
106
+ readonly locations?: ReadonlyArray<SourceLocation>;
107
+ /**
108
+ * If an error can be associated to a particular field in the GraphQL result,
109
+ * it _must_ contain an entry with the key `path` that details the path of
110
+ * the response field which experienced the error. This allows clients to
111
+ * identify whether a null result is intentional or caused by a runtime error.
112
+ */
113
+ readonly path?: ReadonlyArray<string | number>;
114
+ /**
115
+ * Reserved for implementors to extend the protocol however they see fit,
116
+ * and hence there are no additional restrictions on its contents.
117
+ */
118
+ readonly extensions?: {
119
+ [key: string]: unknown;
120
+ };
121
+ }
122
+ interface SourceLocation {
123
+ readonly line: number;
124
+ readonly column: number;
125
+ }
126
+
127
+ export { type ClientConfig as C, type FetchOptions as F, type QueryResult as Q, type SuccessfulQueryResult as S, type WorkniceClient as W, type FailedQueryResult as a, createWorkniceClient as c };
@@ -0,0 +1,12 @@
1
+ declare class ApiError extends Error {
2
+ readonly code: ApiErrorCode;
3
+ constructor(code: ApiErrorCode, options?: ErrorOptions);
4
+ }
5
+ declare enum ApiErrorCode {
6
+ INVALID_QUERY = "INVALID_QUERY",
7
+ NO_PERSON = "NO_PERSON",
8
+ QUERY_EXECUTION_FAILED = "QUERY_EXECUTION_FAILED",
9
+ UNEXPECTED_RESPONSE = "UNEXPECTED_RESPONSE"
10
+ }
11
+
12
+ export { ApiErrorCode, ApiError as default };
@@ -0,0 +1,27 @@
1
+ class ApiError extends Error {
2
+ code;
3
+ constructor(code, options) {
4
+ super(ApiErrorCodeMessage[code], options);
5
+ this.name = "ApiError";
6
+ this.code = code;
7
+ }
8
+ }
9
+ var ApiErrorCode = /* @__PURE__ */ ((ApiErrorCode2) => {
10
+ ApiErrorCode2["INVALID_QUERY"] = "INVALID_QUERY";
11
+ ApiErrorCode2["NO_PERSON"] = "NO_PERSON";
12
+ ApiErrorCode2["QUERY_EXECUTION_FAILED"] = "QUERY_EXECUTION_FAILED";
13
+ ApiErrorCode2["UNEXPECTED_RESPONSE"] = "UNEXPECTED_RESPONSE";
14
+ return ApiErrorCode2;
15
+ })(ApiErrorCode || {});
16
+ const ApiErrorCodeMessage = {
17
+ ["INVALID_QUERY" /* INVALID_QUERY */]: "The GraphQL query could not be executed due to a syntax error, missing information or a validation error.",
18
+ ["NO_PERSON" /* NO_PERSON */]: "No person associated with the session. The session is either in an 'unauthenticated' state (the API token is missing or invalid) or an 'unassociated' state (the user has no active logins).",
19
+ ["QUERY_EXECUTION_FAILED" /* QUERY_EXECUTION_FAILED */]: "An error occurred while executing the GraphQL query. This is likely a problem with the Worknice API.",
20
+ ["UNEXPECTED_RESPONSE" /* UNEXPECTED_RESPONSE */]: "The API returned an unexpected response. This is likely a problem with the Worknice API or a mismatch between JS-SDK and the API. Make sure you are using the latest version of the JS-SDK."
21
+ };
22
+ var ApiError_default = ApiError;
23
+ export {
24
+ ApiErrorCode,
25
+ ApiError_default as default
26
+ };
27
+ //# sourceMappingURL=ApiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/api/ApiError.ts"],"sourcesContent":["class ApiError extends Error {\n readonly code: ApiErrorCode;\n constructor(code: ApiErrorCode, options?: ErrorOptions) {\n super(ApiErrorCodeMessage[code], options);\n this.name = \"ApiError\";\n this.code = code;\n }\n}\n\nenum ApiErrorCode {\n INVALID_QUERY = \"INVALID_QUERY\",\n NO_PERSON = \"NO_PERSON\",\n QUERY_EXECUTION_FAILED = \"QUERY_EXECUTION_FAILED\",\n UNEXPECTED_RESPONSE = \"UNEXPECTED_RESPONSE\",\n}\n\nconst ApiErrorCodeMessage: Record<ApiErrorCode, string> = {\n [ApiErrorCode.INVALID_QUERY]:\n \"The GraphQL query could not be executed due to a syntax error, missing information or a validation error.\",\n [ApiErrorCode.NO_PERSON]:\n \"No person associated with the session. The session is either in an 'unauthenticated' state (the API token is missing or invalid) or an 'unassociated' state (the user has no active logins).\",\n [ApiErrorCode.QUERY_EXECUTION_FAILED]:\n \"An error occurred while executing the GraphQL query. This is likely a problem with the Worknice API.\",\n [ApiErrorCode.UNEXPECTED_RESPONSE]:\n \"The API returned an unexpected response. This is likely a problem with the Worknice API or a mismatch between JS-SDK and the API. Make sure you are using the latest version of the JS-SDK.\",\n} as const;\n\nexport default ApiError;\nexport { ApiErrorCode };\n"],"mappings":"AAAA,MAAM,iBAAiB,MAAM;AAAA,EAClB;AAAA,EACT,YAAY,MAAoB,SAAwB;AACtD,UAAM,oBAAoB,IAAI,GAAG,OAAO;AACxC,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAEA,IAAK,eAAL,kBAAKA,kBAAL;AACE,EAAAA,cAAA,mBAAgB;AAChB,EAAAA,cAAA,eAAY;AACZ,EAAAA,cAAA,4BAAyB;AACzB,EAAAA,cAAA,yBAAsB;AAJnB,SAAAA;AAAA,GAAA;AAOL,MAAM,sBAAoD;AAAA,EACxD,CAAC,mCAA0B,GACzB;AAAA,EACF,CAAC,2BAAsB,GACrB;AAAA,EACF,CAAC,qDAAmC,GAClC;AAAA,EACF,CAAC,+CAAgC,GAC/B;AACJ;AAEA,IAAO,mBAAQ;","names":["ApiErrorCode"]}