@mapcreator/api 5.0.0-alpha.84 → 5.0.0-alpha.86

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 (61) hide show
  1. package/LICENSE +29 -29
  2. package/README.md +86 -86
  3. package/cjs/api/choropleth.d.ts +4 -81
  4. package/cjs/api/choropleth.d.ts.map +1 -1
  5. package/cjs/api/choropleth.js +17 -26
  6. package/cjs/api/choropleth.js.map +1 -1
  7. package/cjs/api/font.d.ts +3 -0
  8. package/cjs/api/font.d.ts.map +1 -1
  9. package/cjs/api/font.js +0 -3
  10. package/cjs/api/font.js.map +1 -1
  11. package/cjs/api/insetMap.d.ts.map +1 -1
  12. package/cjs/api/insetMap.js +3 -5
  13. package/cjs/api/insetMap.js.map +1 -1
  14. package/cjs/api/jobRevision.d.ts.map +1 -1
  15. package/cjs/api/jobRevision.js +4 -6
  16. package/cjs/api/jobRevision.js.map +1 -1
  17. package/cjs/api/resources.d.ts +6 -0
  18. package/cjs/api/resources.d.ts.map +1 -1
  19. package/cjs/api/resources.js +5 -1
  20. package/cjs/api/resources.js.map +1 -1
  21. package/cjs/oauth.d.ts +9 -6
  22. package/cjs/oauth.d.ts.map +1 -1
  23. package/cjs/oauth.js +28 -203
  24. package/cjs/oauth.js.map +1 -1
  25. package/cjs/utils.d.ts.map +1 -1
  26. package/cjs/utils.js +3 -3
  27. package/cjs/utils.js.map +1 -1
  28. package/esm/api/choropleth.d.ts +4 -81
  29. package/esm/api/choropleth.d.ts.map +1 -1
  30. package/esm/api/choropleth.js +16 -23
  31. package/esm/api/choropleth.js.map +1 -1
  32. package/esm/api/font.d.ts +3 -0
  33. package/esm/api/font.d.ts.map +1 -1
  34. package/esm/api/font.js +1 -4
  35. package/esm/api/font.js.map +1 -1
  36. package/esm/api/insetMap.d.ts.map +1 -1
  37. package/esm/api/insetMap.js +4 -6
  38. package/esm/api/insetMap.js.map +1 -1
  39. package/esm/api/jobRevision.d.ts.map +1 -1
  40. package/esm/api/jobRevision.js +4 -6
  41. package/esm/api/jobRevision.js.map +1 -1
  42. package/esm/api/resources.d.ts +6 -0
  43. package/esm/api/resources.d.ts.map +1 -1
  44. package/esm/api/resources.js +5 -1
  45. package/esm/api/resources.js.map +1 -1
  46. package/esm/oauth.d.ts +9 -6
  47. package/esm/oauth.d.ts.map +1 -1
  48. package/esm/oauth.js +27 -201
  49. package/esm/oauth.js.map +1 -1
  50. package/esm/utils.d.ts.map +1 -1
  51. package/esm/utils.js +4 -4
  52. package/esm/utils.js.map +1 -1
  53. package/package.json +80 -80
  54. package/src/README.md +126 -126
  55. package/src/api/choropleth.ts +44 -140
  56. package/src/api/font.ts +12 -4
  57. package/src/api/insetMap.ts +4 -5
  58. package/src/api/jobRevision.ts +4 -5
  59. package/src/api/resources.ts +8 -0
  60. package/src/oauth.ts +28 -258
  61. package/src/utils.ts +4 -4
package/esm/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { apiHost, authenticate, token } from './oauth.js';
1
+ import { apiHost, authenticate, getAuthorizationHeaders, token } from './oauth.js';
2
2
  export const myUser = 'me';
3
3
  export const myOrganisations = 'mine';
4
4
  export const lastJobRevision = 'last';
@@ -130,7 +130,6 @@ export async function request(path, body, extraHeaders, extraOptions) {
130
130
  }
131
131
  function getRequestInit(body, extraHeaders, extraOptions) {
132
132
  var _a;
133
- const authorization = token ? { Authorization: token.toString() } : null;
134
133
  let contentType = null;
135
134
  if (body !== undefined) {
136
135
  switch (true) {
@@ -154,9 +153,10 @@ function getRequestInit(body, extraHeaders, extraOptions) {
154
153
  body = JSON.stringify(body);
155
154
  }
156
155
  }
157
- const headers = Object.assign(Object.assign(Object.assign({ Accept: 'application/json' }, authorization), contentType), extraHeaders);
158
156
  const method = (_a = extraOptions === null || extraOptions === void 0 ? void 0 : extraOptions.method) !== null && _a !== void 0 ? _a : (body != null ? 'POST' : 'GET'); // don't touch `!=` please
159
- return { body, headers, method };
157
+ const authorization = getAuthorizationHeaders(method);
158
+ const headers = Object.assign(Object.assign(Object.assign({ Accept: 'application/json' }, authorization), contentType), extraHeaders);
159
+ return Object.assign({ body, headers, method }, !token && { credentials: 'include' });
160
160
  }
161
161
  export function getContext(revivers, keys = Object.keys(revivers)) {
162
162
  return {
package/esm/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA2B1D,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,YAAY,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;AACvE,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,YAAY,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;AAElG,4CAA4C;AAC5C,MAAM,OAAO,YAAa,SAAQ,KAAK;CAAG;AAE1C,MAAM,OAAO,SAAU,SAAQ,KAAK;IAElC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEjC,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC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AG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAC/B,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,WAAW,CAAoC,IAAa;IAC1E,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,WAAW,CAAgC,GAAW;IAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;AACjC,CAAC;AAED,SAAS,SAAS,CAAgC,GAAW;IAC3D,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;AACjC,CAAC;AAED,SAAS,WAAW,CAAoB,GAAW;IACjD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
- {
2
- "name": "@mapcreator/api",
3
- "version": "5.0.0-alpha.84",
4
- "description": "Mapcreator JavaScript API",
5
- "license": "BSD-3-Clause",
6
- "main": "./cjs/index.js",
7
- "types": "./cjs/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./esm/index.d.ts",
11
- "import": "./esm/index.js",
12
- "require": "./cjs/index.js"
13
- },
14
- "./oauth": {
15
- "types": "./esm/oauth.d.ts",
16
- "import": "./esm/oauth.js",
17
- "require": "./cjs/oauth.js"
18
- },
19
- "./oauth.js": {
20
- "types": "./esm/oauth.d.ts",
21
- "import": "./esm/oauth.js",
22
- "require": "./cjs/oauth.js"
23
- },
24
- "./utils": {
25
- "types": "./esm/utils.d.ts",
26
- "import": "./esm/utils.js",
27
- "require": "./cjs/utils.js"
28
- },
29
- "./utils.js": {
30
- "types": "./esm/utils.d.ts",
31
- "import": "./esm/utils.js",
32
- "require": "./cjs/utils.js"
33
- },
34
- "./package.json": "./package.json",
35
- "./*": {
36
- "types": "./esm/api/*.d.ts",
37
- "import": "./esm/api/*.js",
38
- "require": "./cjs/api/*.js"
39
- },
40
- "./*.js": {
41
- "types": "./esm/api/*.d.ts",
42
- "import": "./esm/api/*.js",
43
- "require": "./cjs/api/*.js"
44
- }
45
- },
46
- "scripts": {
47
- "build": "tsc --outDir esm && tsc -m commonjs --outDir cjs",
48
- "clean": "npx rimraf esm/ cjs/",
49
- "lint": "eslint --ext .ts src",
50
- "prepublishOnly": "npm run lint && npm run clean && npm run build",
51
- "test": "echo \"Error: no test specified\" && exit 1"
52
- },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://gitlab.com/mapcreator/api-wrapper.git"
56
- },
57
- "publishConfig": {
58
- "registry": "https://registry.npmjs.org/"
59
- },
60
- "files": [
61
- "cjs",
62
- "esm",
63
- "src"
64
- ],
65
- "bugs": {
66
- "url": "https://gitlab.com/mapcreator/api-wrapper/issues"
67
- },
68
- "homepage": "https://gitlab.com/mapcreator/api-wrapper#readme",
69
- "dependencies": {
70
- "@types/geojson": "^7946.0.14",
71
- "type-fest": "^4.10"
72
- },
73
- "devDependencies": {
74
- "@stylistic/eslint-plugin": "~1.5",
75
- "@typescript-eslint/eslint-plugin": "~6.15",
76
- "@typescript-eslint/parser": "~6.15",
77
- "eslint": "~8.57",
78
- "typescript": "~5.8.3"
79
- }
80
- }
1
+ {
2
+ "name": "@mapcreator/api",
3
+ "version": "5.0.0-alpha.86",
4
+ "description": "Mapcreator JavaScript API",
5
+ "license": "BSD-3-Clause",
6
+ "main": "./cjs/index.js",
7
+ "types": "./cjs/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./esm/index.d.ts",
11
+ "import": "./esm/index.js",
12
+ "require": "./cjs/index.js"
13
+ },
14
+ "./oauth": {
15
+ "types": "./esm/oauth.d.ts",
16
+ "import": "./esm/oauth.js",
17
+ "require": "./cjs/oauth.js"
18
+ },
19
+ "./oauth.js": {
20
+ "types": "./esm/oauth.d.ts",
21
+ "import": "./esm/oauth.js",
22
+ "require": "./cjs/oauth.js"
23
+ },
24
+ "./utils": {
25
+ "types": "./esm/utils.d.ts",
26
+ "import": "./esm/utils.js",
27
+ "require": "./cjs/utils.js"
28
+ },
29
+ "./utils.js": {
30
+ "types": "./esm/utils.d.ts",
31
+ "import": "./esm/utils.js",
32
+ "require": "./cjs/utils.js"
33
+ },
34
+ "./package.json": "./package.json",
35
+ "./*": {
36
+ "types": "./esm/api/*.d.ts",
37
+ "import": "./esm/api/*.js",
38
+ "require": "./cjs/api/*.js"
39
+ },
40
+ "./*.js": {
41
+ "types": "./esm/api/*.d.ts",
42
+ "import": "./esm/api/*.js",
43
+ "require": "./cjs/api/*.js"
44
+ }
45
+ },
46
+ "scripts": {
47
+ "build": "tsc --outDir esm && tsc -m commonjs --outDir cjs",
48
+ "clean": "npx rimraf esm/ cjs/",
49
+ "lint": "eslint --ext .ts src",
50
+ "prepublishOnly": "npm run lint && npm run clean && npm run build",
51
+ "test": "echo \"Error: no test specified\" && exit 1"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://gitlab.com/mapcreator/api-wrapper.git"
56
+ },
57
+ "publishConfig": {
58
+ "registry": "https://registry.npmjs.org/"
59
+ },
60
+ "files": [
61
+ "cjs",
62
+ "esm",
63
+ "src"
64
+ ],
65
+ "bugs": {
66
+ "url": "https://gitlab.com/mapcreator/api-wrapper/issues"
67
+ },
68
+ "homepage": "https://gitlab.com/mapcreator/api-wrapper#readme",
69
+ "dependencies": {
70
+ "@types/geojson": "^7946.0.14",
71
+ "type-fest": "^4.10"
72
+ },
73
+ "devDependencies": {
74
+ "@stylistic/eslint-plugin": "~1.5",
75
+ "@typescript-eslint/eslint-plugin": "~6.15",
76
+ "@typescript-eslint/parser": "~6.15",
77
+ "eslint": "~8.57",
78
+ "typescript": "~5.8.3"
79
+ }
80
+ }
package/src/README.md CHANGED
@@ -1,126 +1,126 @@
1
- ### Used type system
2
-
3
- We use type declarations for both the data coming over the wire and the data used by the application. In general, these types differ only in the presence of additional fields in the data arriving over the network (like `created_at`), and used naming convention. Data over the network uses the so-called snake case.
4
-
5
- All in all, we can use TypeScript's native mechanisms to convert one type to another and fully define just one type:
6
-
7
- ```typescript
8
- import type { CamelCasedProperties } from 'type-fest';
9
-
10
- type ApiType =
11
- | ({
12
- data: {
13
- prop: unknown;
14
- } & ApiCommonData;
15
- } & Omit<ApiSuccess, 'data'>)
16
- | ApiError;
17
-
18
- type AppType = CamelCasedProperties<Omit<Exclude<ApiType, ApiError>['data'], keyof ApiCommonData>>;
19
- ```
20
-
21
- or in reverse order:
22
-
23
- ```typescript
24
- import type { SnakeCasedProperties } from 'type-fest';
25
-
26
- type AppType = {
27
- prop: unknown;
28
- };
29
-
30
- type ApiType =
31
- | ({
32
- data: SnakeCasedProperties<AppType> & ApiCommonData;
33
- } & Omit<ApiSuccess, 'data'>)
34
- | ApiError;
35
- ```
36
-
37
- But the decision was made not to do this, since it may be more difficult for the developer to make the conversion in their head than to see it in front of their eyes.
38
-
39
- ### Using a `request()`
40
-
41
- The function has the following signature:
42
-
43
- ```typescript
44
- async function request<I extends ApiCommon, O extends Record<string, unknown> | string>(
45
- path: string,
46
- body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null,
47
- extraHeaders?: Record<string, string> | null,
48
- extraOptions?: ExtraOptions<I, O>,
49
- ): Promise<O | O[]> { /* ... */ }
50
- ```
51
-
52
- Let's take it step by step.
53
-
54
- `I extends ApiCommon` - represents the type of data we receive over the network.
55
-
56
- `O extends Record<string, unknown> | string` - represents the data type that will be used in the application.
57
-
58
- Ideally you should describe and convey both types. This will help to check the data types in the arguments passed.
59
- See current data types for an example.
60
-
61
- `path: string` - the path to the resource, must include the API version, but must not include the schema or authority.
62
- Example: `/v1/jobs/12345`
63
-
64
- `body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null` - any meaningful body type. In general,
65
- the presence of an JSON object is assumed (or the absence of one for methods that only request data), but you can
66
- also pass `Blob`, `FormData`, `URLSearchParams` or just `ArrayBuffer`. The required content type will be added to
67
- the headers automatically.
68
-
69
- `extraHeaders?: Record<string, string> | null` - the object with additional headers.
70
-
71
- `extraOptions?: ExtraOptions<I, O>` - where `ExtraOptions<I, O>` is defined like this:
72
-
73
- ```typescript
74
- interface ExtraOptions<I extends ApiCommon, O extends Record<string, unknown> | string> {
75
- method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
76
- revivers?: O extends Record<string, unknown> ? Revivers<I, O> : never;
77
- sendNull?: boolean;
78
- withMeta?: boolean;
79
- }
80
- ```
81
-
82
- Most fields are self-explanatory.
83
-
84
- `sendNull` can be used if you really want to pass `null` as body content.
85
-
86
- `revivers` is used to specify an object that can modify the behavior of the internal handler of data coming over
87
- the network. Let's take a closer look at this moment.
88
-
89
- #### Revivers
90
-
91
- By default, the `request()` function does the following things with data coming over the network:
92
-
93
- - It removes `created_at`, `updated_at`, `deleted_at` fields from the output objects.
94
- - It preserves all the remaining fields but converts their names into camelCase.
95
-
96
- When passing an object with revivers you can a couple of things:
97
-
98
- - You can list the fields that you want **to exclude** from the result object. To do this, the field must be assigned an
99
- `undefined` value.
100
- - You can **add** new fields or **modify** the type of existing ones. To do this, you need to pass a function as a field
101
- value, which will receive the original object as input.
102
-
103
- Example:
104
-
105
- ```typescript
106
- const jobRevivers: Revivers<ApiJob, Job> = {
107
- user_id: undefined,
108
- description: undefined,
109
- share_token: undefined,
110
- autosave_preview_path: undefined,
111
- job_folder_id: undefined,
112
-
113
- jobTypeId: () => 9,
114
- createdAt: (data: ApiJobData) => data.created_at as string,
115
- previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
116
- };
117
- ```
118
-
119
- `user_id`, `description`, `share_token`, `autosave_preview_path`, `job_folder_id` fields will be excluded from the
120
- result object.
121
-
122
- `jobTypeId` will be always **9**.
123
-
124
- `createdAt` will be returned (please note that that field is excluded by default)
125
-
126
- `previewPath` - some actions will be performed with the source data.
1
+ ### Used type system
2
+
3
+ We use type declarations for both the data coming over the wire and the data used by the application. In general, these types differ only in the presence of additional fields in the data arriving over the network (like `created_at`), and used naming convention. Data over the network uses the so-called snake case.
4
+
5
+ All in all, we can use TypeScript's native mechanisms to convert one type to another and fully define just one type:
6
+
7
+ ```typescript
8
+ import type { CamelCasedProperties } from 'type-fest';
9
+
10
+ type ApiType =
11
+ | ({
12
+ data: {
13
+ prop: unknown;
14
+ } & ApiCommonData;
15
+ } & Omit<ApiSuccess, 'data'>)
16
+ | ApiError;
17
+
18
+ type AppType = CamelCasedProperties<Omit<Exclude<ApiType, ApiError>['data'], keyof ApiCommonData>>;
19
+ ```
20
+
21
+ or in reverse order:
22
+
23
+ ```typescript
24
+ import type { SnakeCasedProperties } from 'type-fest';
25
+
26
+ type AppType = {
27
+ prop: unknown;
28
+ };
29
+
30
+ type ApiType =
31
+ | ({
32
+ data: SnakeCasedProperties<AppType> & ApiCommonData;
33
+ } & Omit<ApiSuccess, 'data'>)
34
+ | ApiError;
35
+ ```
36
+
37
+ But the decision was made not to do this, since it may be more difficult for the developer to make the conversion in their head than to see it in front of their eyes.
38
+
39
+ ### Using a `request()`
40
+
41
+ The function has the following signature:
42
+
43
+ ```typescript
44
+ async function request<I extends ApiCommon, O extends Record<string, unknown> | string>(
45
+ path: string,
46
+ body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null,
47
+ extraHeaders?: Record<string, string> | null,
48
+ extraOptions?: ExtraOptions<I, O>,
49
+ ): Promise<O | O[]> { /* ... */ }
50
+ ```
51
+
52
+ Let's take it step by step.
53
+
54
+ `I extends ApiCommon` - represents the type of data we receive over the network.
55
+
56
+ `O extends Record<string, unknown> | string` - represents the data type that will be used in the application.
57
+
58
+ Ideally you should describe and convey both types. This will help to check the data types in the arguments passed.
59
+ See current data types for an example.
60
+
61
+ `path: string` - the path to the resource, must include the API version, but must not include the schema or authority.
62
+ Example: `/v1/jobs/12345`
63
+
64
+ `body?: XMLHttpRequestBodyInit | Record<string | number, unknown> | null` - any meaningful body type. In general,
65
+ the presence of an JSON object is assumed (or the absence of one for methods that only request data), but you can
66
+ also pass `Blob`, `FormData`, `URLSearchParams` or just `ArrayBuffer`. The required content type will be added to
67
+ the headers automatically.
68
+
69
+ `extraHeaders?: Record<string, string> | null` - the object with additional headers.
70
+
71
+ `extraOptions?: ExtraOptions<I, O>` - where `ExtraOptions<I, O>` is defined like this:
72
+
73
+ ```typescript
74
+ interface ExtraOptions<I extends ApiCommon, O extends Record<string, unknown> | string> {
75
+ method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
76
+ revivers?: O extends Record<string, unknown> ? Revivers<I, O> : never;
77
+ sendNull?: boolean;
78
+ withMeta?: boolean;
79
+ }
80
+ ```
81
+
82
+ Most fields are self-explanatory.
83
+
84
+ `sendNull` can be used if you really want to pass `null` as body content.
85
+
86
+ `revivers` is used to specify an object that can modify the behavior of the internal handler of data coming over
87
+ the network. Let's take a closer look at this moment.
88
+
89
+ #### Revivers
90
+
91
+ By default, the `request()` function does the following things with data coming over the network:
92
+
93
+ - It removes `created_at`, `updated_at`, `deleted_at` fields from the output objects.
94
+ - It preserves all the remaining fields but converts their names into camelCase.
95
+
96
+ When passing an object with revivers you can a couple of things:
97
+
98
+ - You can list the fields that you want **to exclude** from the result object. To do this, the field must be assigned an
99
+ `undefined` value.
100
+ - You can **add** new fields or **modify** the type of existing ones. To do this, you need to pass a function as a field
101
+ value, which will receive the original object as input.
102
+
103
+ Example:
104
+
105
+ ```typescript
106
+ const jobRevivers: Revivers<ApiJob, Job> = {
107
+ user_id: undefined,
108
+ description: undefined,
109
+ share_token: undefined,
110
+ autosave_preview_path: undefined,
111
+ job_folder_id: undefined,
112
+
113
+ jobTypeId: () => 9,
114
+ createdAt: (data: ApiJobData) => data.created_at as string,
115
+ previewPath: (data: ApiJobData) => data.autosave_preview_path ?? undefined,
116
+ };
117
+ ```
118
+
119
+ `user_id`, `description`, `share_token`, `autosave_preview_path`, `job_folder_id` fields will be excluded from the
120
+ result object.
121
+
122
+ `jobTypeId` will be always **9**.
123
+
124
+ `createdAt` will be returned (please note that that field is excluded by default)
125
+
126
+ `previewPath` - some actions will be performed with the source data.