@deliverart/sdk-js-company 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.
package/dist/index.js ADDED
@@ -0,0 +1,176 @@
1
+ // src/models.ts
2
+ import { addressSchema, billingDataSchema, datetimeSchema } from "@deliverart/sdk-js-global-types";
3
+ import { z } from "zod";
4
+ var companySchema = z.object({
5
+ id: z.string(),
6
+ businessName: z.string(),
7
+ vat: z.string(),
8
+ taxCode: z.string(),
9
+ operationalAddress: addressSchema,
10
+ createdAt: datetimeSchema,
11
+ updatedAt: datetimeSchema
12
+ });
13
+ var companyDetailsSchema = companySchema.extend({
14
+ billingAddress: addressSchema,
15
+ billingData: billingDataSchema,
16
+ adminBy: z.string()
17
+ });
18
+ var writableCompanySchema = companyDetailsSchema.pick({
19
+ businessName: true,
20
+ vat: true,
21
+ taxCode: true,
22
+ billingAddress: true,
23
+ operationalAddress: true,
24
+ billingData: true
25
+ });
26
+
27
+ // src/requests/CreateCompany.ts
28
+ import { AbstractApiRequest } from "@deliverart/sdk-js-core";
29
+ var createCompanyInputSchema = writableCompanySchema.required();
30
+ var createCompanyResponseSchema = companyDetailsSchema;
31
+ var CreateCompany = class extends AbstractApiRequest {
32
+ method = "POST";
33
+ contentType = "application/json";
34
+ accept = "application/json";
35
+ inputSchema = createCompanyInputSchema;
36
+ outputSchema = createCompanyResponseSchema;
37
+ querySchema = void 0;
38
+ headersSchema = void 0;
39
+ constructor(input) {
40
+ super(input);
41
+ }
42
+ getPath() {
43
+ return "/companies";
44
+ }
45
+ };
46
+
47
+ // src/requests/DeleteCompany.ts
48
+ import { AbstractApiRequest as AbstractApiRequest2 } from "@deliverart/sdk-js-core";
49
+ import { z as z2 } from "zod";
50
+ var deleteCompanyInputSchema = z2.undefined();
51
+ var deleteCompanyResponseSchema = z2.undefined();
52
+ var DeleteCompany = class extends AbstractApiRequest2 {
53
+ method = "DELETE";
54
+ contentType = "application/json";
55
+ accept = "application/json";
56
+ inputSchema = deleteCompanyInputSchema;
57
+ outputSchema = deleteCompanyResponseSchema;
58
+ querySchema = void 0;
59
+ headersSchema = void 0;
60
+ companyId;
61
+ constructor(companyId) {
62
+ super();
63
+ this.companyId = companyId;
64
+ }
65
+ getPath() {
66
+ return `/companies/${this.companyId}`;
67
+ }
68
+ };
69
+
70
+ // src/requests/GetCompanies.ts
71
+ import { AbstractApiRequest as AbstractApiRequest3 } from "@deliverart/sdk-js-core";
72
+ import {
73
+ createPaginatedSchema,
74
+ responseToPagination
75
+ } from "@deliverart/sdk-js-global-types";
76
+ import { z as z3 } from "zod";
77
+ var getCompaniesQuerySchema = z3.object({
78
+ businessName: z3.string().optional(),
79
+ vat: z3.string().optional(),
80
+ taxCode: z3.string().optional(),
81
+ "billingAddress.city": z3.string().optional(),
82
+ "billingAddress.postalCode": z3.string().optional(),
83
+ "operationalAddress.city": z3.string().optional(),
84
+ "operationalAddress.postalCode": z3.string().optional(),
85
+ "order[businessName]": z3.enum(["asc", "desc"]).optional(),
86
+ "order[createdAt]": z3.enum(["asc", "desc"]).optional(),
87
+ "order[updatedAt]": z3.enum(["asc", "desc"]).optional(),
88
+ page: z3.coerce.number().optional()
89
+ });
90
+ var getCompaniesResponseSchema = createPaginatedSchema(companySchema);
91
+ var getCompaniesInputSchema = z3.undefined();
92
+ var GetCompanies = class extends AbstractApiRequest3 {
93
+ method = "GET";
94
+ contentType = "application/json";
95
+ accept = "application/json";
96
+ inputSchema = getCompaniesInputSchema;
97
+ outputSchema = getCompaniesResponseSchema;
98
+ querySchema = getCompaniesQuerySchema;
99
+ headersSchema = void 0;
100
+ constructor(options) {
101
+ super(void 0, options);
102
+ }
103
+ getPath() {
104
+ return "/companies";
105
+ }
106
+ parseResponse(data, rawResponse) {
107
+ const companies = z3.array(companySchema).parse(data);
108
+ return this.validateOutput({ data: companies, pagination: responseToPagination(rawResponse) });
109
+ }
110
+ };
111
+
112
+ // src/requests/GetCompanyDetails.ts
113
+ import { AbstractApiRequest as AbstractApiRequest4 } from "@deliverart/sdk-js-core";
114
+ import { z as z4 } from "zod";
115
+ var getCompanyDetailsInputSchema = z4.undefined();
116
+ var getCompanyDetailsResponseSchema = companyDetailsSchema;
117
+ var GetCompanyDetails = class extends AbstractApiRequest4 {
118
+ method = "GET";
119
+ contentType = "application/json";
120
+ accept = "application/json";
121
+ inputSchema = getCompanyDetailsInputSchema;
122
+ outputSchema = getCompanyDetailsResponseSchema;
123
+ querySchema = void 0;
124
+ headersSchema = void 0;
125
+ companyId;
126
+ constructor(companyId) {
127
+ super();
128
+ this.companyId = companyId;
129
+ }
130
+ getPath() {
131
+ return `/companies/${this.companyId}`;
132
+ }
133
+ };
134
+
135
+ // src/requests/UpdateCompany.ts
136
+ import { AbstractApiRequest as AbstractApiRequest5 } from "@deliverart/sdk-js-core";
137
+ var updateCompanyInputSchema = writableCompanySchema.partial();
138
+ var updateCompanyResponseSchema = companyDetailsSchema;
139
+ var UpdateCompany = class extends AbstractApiRequest5 {
140
+ method = "PATCH";
141
+ contentType = "application/merge-patch+json";
142
+ accept = "application/json";
143
+ inputSchema = updateCompanyInputSchema;
144
+ outputSchema = updateCompanyResponseSchema;
145
+ querySchema = void 0;
146
+ headersSchema = void 0;
147
+ companyId;
148
+ constructor(companyId, input) {
149
+ super(input);
150
+ this.companyId = companyId;
151
+ }
152
+ getPath() {
153
+ return `/companies/${this.companyId}`;
154
+ }
155
+ };
156
+ export {
157
+ CreateCompany,
158
+ DeleteCompany,
159
+ GetCompanies,
160
+ GetCompanyDetails,
161
+ UpdateCompany,
162
+ companyDetailsSchema,
163
+ companySchema,
164
+ createCompanyInputSchema,
165
+ createCompanyResponseSchema,
166
+ deleteCompanyInputSchema,
167
+ deleteCompanyResponseSchema,
168
+ getCompaniesInputSchema,
169
+ getCompaniesQuerySchema,
170
+ getCompaniesResponseSchema,
171
+ getCompanyDetailsInputSchema,
172
+ getCompanyDetailsResponseSchema,
173
+ updateCompanyInputSchema,
174
+ updateCompanyResponseSchema,
175
+ writableCompanySchema
176
+ };
@@ -0,0 +1,41 @@
1
+ /* eslint-disable */
2
+ // eslint.config.js per @typescript-eslint v8
3
+ import js from '@eslint/js'
4
+ import prettier from 'eslint-config-prettier'
5
+ import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort'
6
+ import tsPlugin from '@typescript-eslint/eslint-plugin'
7
+ import tsParser from '@typescript-eslint/parser'
8
+
9
+ export default [
10
+ js.configs.recommended,
11
+ {
12
+ files: ['**/*.ts'],
13
+ languageOptions: {
14
+ parser: tsParser,
15
+ globals: {
16
+ process: 'readonly',
17
+ fetch: 'readonly',
18
+ Request: 'readonly',
19
+ Response: 'readonly',
20
+ Headers: 'readonly',
21
+ },
22
+ parserOptions: {
23
+ project: ['./tsconfig.json'],
24
+ tsconfigRootDir: process.cwd(),
25
+ sourceType: 'module',
26
+ },
27
+ },
28
+ plugins: {
29
+ '@typescript-eslint': tsPlugin,
30
+ 'simple-import-sort': simpleImportSortPlugin,
31
+ },
32
+ rules: {
33
+ 'simple-import-sort/imports': 'error',
34
+ 'simple-import-sort/exports': 'error',
35
+ '@typescript-eslint/no-unused-vars': 'warn',
36
+ },
37
+ },
38
+ prettier,
39
+ ]
40
+
41
+ export const ignores = ['dist', 'node_modules']
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@deliverart/sdk-js-company",
3
+ "description": "Deliverart JavaScript SDK for User Management",
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "zod": "3.25.67",
16
+ "axios": "1.9.0",
17
+ "@deliverart/sdk-js-core": "0.1.3",
18
+ "@deliverart/sdk-js-global-types": "0.0.8"
19
+ },
20
+ "devDependencies": {
21
+ "@changesets/cli": "^2.29.4",
22
+ "@eslint/js": "9.28.0",
23
+ "@types/node": "22.15.30",
24
+ "@typescript-eslint/eslint-plugin": "8.33.1",
25
+ "@typescript-eslint/parser": "8.33.1",
26
+ "eslint": "9.28.0",
27
+ "eslint-config-prettier": "10.1.5",
28
+ "eslint-plugin-simple-import-sort": "12.1.1",
29
+ "prettier": "3.5.3",
30
+ "tsup": "8.5.0",
31
+ "typescript": "5.8.3"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --dts --format esm,cjs",
38
+ "dev": "tsup src/index.ts --dts --watch",
39
+ "lint": "eslint .",
40
+ "lint:fix": "eslint . --fix",
41
+ "prettier": "prettier --check .",
42
+ "prettier:fix": "prettier --write .",
43
+ "version": "@changesets/cli version",
44
+ "release": "@changesets/cli publish"
45
+ }
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './models'
2
+ export * from './requests'
package/src/models.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { addressSchema, billingDataSchema, datetimeSchema } from '@deliverart/sdk-js-global-types'
2
+ import { z } from 'zod'
3
+
4
+ export const companySchema = z.object({
5
+ id: z.string(),
6
+ businessName: z.string(),
7
+ vat: z.string(),
8
+ taxCode: z.string(),
9
+ operationalAddress: addressSchema,
10
+ createdAt: datetimeSchema,
11
+ updatedAt: datetimeSchema,
12
+ })
13
+ export type Company = z.infer<typeof companySchema>
14
+
15
+ export const companyDetailsSchema = companySchema.extend({
16
+ billingAddress: addressSchema,
17
+ billingData: billingDataSchema,
18
+ adminBy: z.string(),
19
+ })
20
+ export type CompanyDetails = z.infer<typeof companyDetailsSchema>
21
+
22
+ export const writableCompanySchema = companyDetailsSchema.pick({
23
+ businessName: true,
24
+ vat: true,
25
+ taxCode: true,
26
+ billingAddress: true,
27
+ operationalAddress: true,
28
+ billingData: true,
29
+ })
@@ -0,0 +1,29 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import { CompanyDetails, companyDetailsSchema, writableCompanySchema } from '../models'
5
+
6
+ export const createCompanyInputSchema = writableCompanySchema.required()
7
+ export type CreateCompanyInput = z.infer<typeof createCompanyInputSchema>
8
+
9
+ export const createCompanyResponseSchema = companyDetailsSchema
10
+ export type CreateCompanyResponse = CompanyDetails
11
+
12
+ export class CreateCompany extends AbstractApiRequest<CreateCompanyInput, CreateCompanyResponse> {
13
+ readonly method = 'POST'
14
+ readonly contentType = 'application/json'
15
+ readonly accept = 'application/json'
16
+
17
+ readonly inputSchema = createCompanyInputSchema
18
+ readonly outputSchema = createCompanyResponseSchema
19
+ readonly querySchema = undefined
20
+ readonly headersSchema = undefined
21
+
22
+ constructor(input: CreateCompanyInput) {
23
+ super(input)
24
+ }
25
+
26
+ getPath(): string {
27
+ return '/companies'
28
+ }
29
+ }
@@ -0,0 +1,27 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ export const deleteCompanyInputSchema = z.undefined()
5
+ export const deleteCompanyResponseSchema = z.undefined()
6
+
7
+ export class DeleteCompany extends AbstractApiRequest<void, void> {
8
+ readonly method = 'DELETE'
9
+ readonly contentType = 'application/json'
10
+ readonly accept = 'application/json'
11
+
12
+ readonly inputSchema = deleteCompanyInputSchema
13
+ readonly outputSchema = deleteCompanyResponseSchema
14
+ readonly querySchema = undefined
15
+ readonly headersSchema = undefined
16
+
17
+ private readonly companyId: string
18
+
19
+ constructor(companyId: string) {
20
+ super()
21
+ this.companyId = companyId
22
+ }
23
+
24
+ getPath(): string {
25
+ return `/companies/${this.companyId}`
26
+ }
27
+ }
@@ -0,0 +1,58 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import {
3
+ createPaginatedSchema,
4
+ Paginated,
5
+ responseToPagination,
6
+ } from '@deliverart/sdk-js-global-types'
7
+ import { AxiosResponse } from 'axios'
8
+ import { z } from 'zod'
9
+
10
+ import { Company, companySchema } from '../models'
11
+
12
+ export const getCompaniesQuerySchema = z.object({
13
+ businessName: z.string().optional(),
14
+ vat: z.string().optional(),
15
+ taxCode: z.string().optional(),
16
+ 'billingAddress.city': z.string().optional(),
17
+ 'billingAddress.postalCode': z.string().optional(),
18
+ 'operationalAddress.city': z.string().optional(),
19
+ 'operationalAddress.postalCode': z.string().optional(),
20
+ 'order[businessName]': z.enum(['asc', 'desc']).optional(),
21
+ 'order[createdAt]': z.enum(['asc', 'desc']).optional(),
22
+ 'order[updatedAt]': z.enum(['asc', 'desc']).optional(),
23
+ page: z.coerce.number().optional(),
24
+ })
25
+ export type GetCompaniesQueryParams = z.infer<typeof getCompaniesQuerySchema>
26
+
27
+ export const getCompaniesResponseSchema = createPaginatedSchema(companySchema)
28
+ export type GetCompaniesResponse = z.infer<typeof getCompaniesResponseSchema>
29
+
30
+ export const getCompaniesInputSchema = z.undefined()
31
+
32
+ export class GetCompanies extends AbstractApiRequest<
33
+ void,
34
+ GetCompaniesResponse,
35
+ GetCompaniesQueryParams
36
+ > {
37
+ readonly method = 'GET'
38
+ readonly contentType = 'application/json'
39
+ readonly accept = 'application/json'
40
+
41
+ readonly inputSchema = getCompaniesInputSchema
42
+ readonly outputSchema = getCompaniesResponseSchema
43
+ readonly querySchema = getCompaniesQuerySchema
44
+ readonly headersSchema = undefined
45
+
46
+ constructor(options?: { query?: GetCompaniesQueryParams }) {
47
+ super(undefined, options)
48
+ }
49
+
50
+ getPath(): string {
51
+ return '/companies'
52
+ }
53
+
54
+ parseResponse(data: unknown, rawResponse: AxiosResponse): Paginated<Company> {
55
+ const companies = z.array(companySchema).parse(data)
56
+ return this.validateOutput({ data: companies, pagination: responseToPagination(rawResponse) })
57
+ }
58
+ }
@@ -0,0 +1,30 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import { CompanyDetails, companyDetailsSchema } from '../models'
5
+
6
+ export const getCompanyDetailsInputSchema = z.undefined()
7
+
8
+ export const getCompanyDetailsResponseSchema = companyDetailsSchema
9
+ export type GetCompanyDetailsResponse = CompanyDetails
10
+
11
+ export class GetCompanyDetails extends AbstractApiRequest<void, GetCompanyDetailsResponse> {
12
+ readonly method = 'GET'
13
+ readonly contentType = 'application/json'
14
+ readonly accept = 'application/json'
15
+ readonly inputSchema = getCompanyDetailsInputSchema
16
+ readonly outputSchema = getCompanyDetailsResponseSchema
17
+ readonly querySchema = undefined
18
+ readonly headersSchema = undefined
19
+
20
+ private readonly companyId: string
21
+
22
+ constructor(companyId: string) {
23
+ super()
24
+ this.companyId = companyId
25
+ }
26
+
27
+ getPath(): string {
28
+ return `/companies/${this.companyId}`
29
+ }
30
+ }
@@ -0,0 +1,32 @@
1
+ import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
+ import { z } from 'zod'
3
+
4
+ import { CompanyDetails, companyDetailsSchema, writableCompanySchema } from '../models'
5
+
6
+ export const updateCompanyInputSchema = writableCompanySchema.partial()
7
+ export type UpdateCompanyInput = z.infer<typeof updateCompanyInputSchema>
8
+
9
+ export const updateCompanyResponseSchema = companyDetailsSchema
10
+ export type UpdateCompanyResponse = CompanyDetails
11
+
12
+ export class UpdateCompany extends AbstractApiRequest<UpdateCompanyInput, UpdateCompanyResponse> {
13
+ readonly method = 'PATCH'
14
+ readonly contentType = 'application/merge-patch+json'
15
+ readonly accept = 'application/json'
16
+
17
+ readonly inputSchema = updateCompanyInputSchema
18
+ readonly outputSchema = updateCompanyResponseSchema
19
+ readonly querySchema = undefined
20
+ readonly headersSchema = undefined
21
+
22
+ private readonly companyId: string
23
+
24
+ constructor(companyId: string, input: UpdateCompanyInput) {
25
+ super(input)
26
+ this.companyId = companyId
27
+ }
28
+
29
+ getPath(): string {
30
+ return `/companies/${this.companyId}`
31
+ }
32
+ }
@@ -0,0 +1,5 @@
1
+ export * from './CreateCompany'
2
+ export * from './DeleteCompany'
3
+ export * from './GetCompanies'
4
+ export * from './GetCompanyDetails'
5
+ export * from './UpdateCompany'
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "outDir": "dist",
11
+ "declaration": true,
12
+ "declarationMap": true
13
+ },
14
+ "include": ["src"]
15
+ }