@abyss-project/link 0.0.0-stage → 1.0.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 (118) hide show
  1. package/.eslintrc.js +32 -0
  2. package/.prettierrc +5 -0
  3. package/README.md +21 -2
  4. package/dist/api/abyss.admin.api.d.ts +4 -0
  5. package/dist/api/abyss.admin.api.js +17 -0
  6. package/dist/api/abyss.admin.api.js.map +1 -0
  7. package/dist/api/index.d.ts +1 -0
  8. package/dist/api/index.js +18 -0
  9. package/dist/api/index.js.map +1 -0
  10. package/dist/constants/index.d.ts +1 -0
  11. package/dist/constants/index.js +18 -0
  12. package/dist/constants/index.js.map +1 -0
  13. package/dist/constants/link.constants.d.ts +14 -0
  14. package/dist/constants/link.constants.js +37 -0
  15. package/dist/constants/link.constants.js.map +1 -0
  16. package/dist/index.d.ts +33 -0
  17. package/dist/index.js +120 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/types/enum/api-error.enum.d.ts +16 -0
  20. package/dist/types/enum/api-error.enum.js +22 -0
  21. package/dist/types/enum/api-error.enum.js.map +1 -0
  22. package/dist/types/enum/index.d.ts +2 -0
  23. package/dist/types/enum/index.js +19 -0
  24. package/dist/types/enum/index.js.map +1 -0
  25. package/dist/types/enum/link.enum.d.ts +20 -0
  26. package/dist/types/enum/link.enum.js +27 -0
  27. package/dist/types/enum/link.enum.js.map +1 -0
  28. package/dist/types/index.d.ts +2 -0
  29. package/dist/types/index.js +19 -0
  30. package/dist/types/index.js.map +1 -0
  31. package/dist/types/interface/api/index.d.ts +5 -0
  32. package/dist/types/interface/api/index.js +22 -0
  33. package/dist/types/interface/api/index.js.map +1 -0
  34. package/dist/types/interface/api/requests/abyss.admin.request.d.ts +14 -0
  35. package/dist/types/interface/api/requests/abyss.admin.request.js +3 -0
  36. package/dist/types/interface/api/requests/abyss.admin.request.js.map +1 -0
  37. package/dist/types/interface/api/requests/index.d.ts +1 -0
  38. package/dist/types/interface/api/requests/index.js +18 -0
  39. package/dist/types/interface/api/requests/index.js.map +1 -0
  40. package/dist/types/interface/api/responses/abyss.admin.response.d.ts +14 -0
  41. package/dist/types/interface/api/responses/abyss.admin.response.js +3 -0
  42. package/dist/types/interface/api/responses/abyss.admin.response.js.map +1 -0
  43. package/dist/types/interface/api/responses/index.d.ts +1 -0
  44. package/dist/types/interface/api/responses/index.js +18 -0
  45. package/dist/types/interface/api/responses/index.js.map +1 -0
  46. package/dist/types/interface/api/type-message/api-error.d.ts +6 -0
  47. package/dist/types/interface/api/type-message/api-error.js +3 -0
  48. package/dist/types/interface/api/type-message/api-error.js.map +1 -0
  49. package/dist/types/interface/api/type-message/base-paginate.d.ts +10 -0
  50. package/dist/types/interface/api/type-message/base-paginate.js +3 -0
  51. package/dist/types/interface/api/type-message/base-paginate.js.map +1 -0
  52. package/dist/types/interface/api/type-message/response.d.ts +5 -0
  53. package/dist/types/interface/api/type-message/response.js +3 -0
  54. package/dist/types/interface/api/type-message/response.js.map +1 -0
  55. package/dist/types/interface/index.d.ts +2 -0
  56. package/dist/types/interface/index.js +19 -0
  57. package/dist/types/interface/index.js.map +1 -0
  58. package/dist/types/interface/models/index.d.ts +4 -0
  59. package/dist/types/interface/models/index.js +21 -0
  60. package/dist/types/interface/models/index.js.map +1 -0
  61. package/dist/types/interface/models/link.dto.d.ts +91 -0
  62. package/dist/types/interface/models/link.dto.js +3 -0
  63. package/dist/types/interface/models/link.dto.js.map +1 -0
  64. package/dist/types/interface/models/organization.dto.d.ts +11 -0
  65. package/dist/types/interface/models/organization.dto.js +3 -0
  66. package/dist/types/interface/models/organization.dto.js.map +1 -0
  67. package/dist/types/interface/models/project.dto.d.ts +12 -0
  68. package/dist/types/interface/models/project.dto.js +3 -0
  69. package/dist/types/interface/models/project.dto.js.map +1 -0
  70. package/dist/types/interface/models/user.dto.d.ts +11 -0
  71. package/dist/types/interface/models/user.dto.js +3 -0
  72. package/dist/types/interface/models/user.dto.js.map +1 -0
  73. package/dist/utils/enum.utils.d.ts +1 -0
  74. package/dist/utils/enum.utils.js +3 -0
  75. package/dist/utils/enum.utils.js.map +1 -0
  76. package/dist/utils/error.utils.d.ts +15 -0
  77. package/dist/utils/error.utils.js +25 -0
  78. package/dist/utils/error.utils.js.map +1 -0
  79. package/dist/utils/index.d.ts +3 -0
  80. package/dist/utils/index.js +20 -0
  81. package/dist/utils/index.js.map +1 -0
  82. package/dist/utils/link-slug.utils.d.ts +1 -0
  83. package/dist/utils/link-slug.utils.js +11 -0
  84. package/dist/utils/link-slug.utils.js.map +1 -0
  85. package/jest.config.cjs +9 -0
  86. package/package.json +56 -3
  87. package/src/api/abyss.admin.api.ts +39 -0
  88. package/src/api/index.ts +1 -0
  89. package/src/constants/index.ts +1 -0
  90. package/src/constants/link.constants.ts +49 -0
  91. package/src/constants/tests/link-forbidden-slugs.spec.ts +103 -0
  92. package/src/index.ts +109 -0
  93. package/src/tests/sdk-surface.spec.ts +63 -0
  94. package/src/types/enum/api-error.enum.ts +18 -0
  95. package/src/types/enum/index.ts +2 -0
  96. package/src/types/enum/link.enum.ts +34 -0
  97. package/src/types/index.ts +2 -0
  98. package/src/types/interface/api/index.ts +5 -0
  99. package/src/types/interface/api/requests/abyss.admin.request.ts +17 -0
  100. package/src/types/interface/api/requests/index.ts +1 -0
  101. package/src/types/interface/api/responses/abyss.admin.response.ts +17 -0
  102. package/src/types/interface/api/responses/index.ts +1 -0
  103. package/src/types/interface/api/type-message/api-error.ts +7 -0
  104. package/src/types/interface/api/type-message/base-paginate.ts +11 -0
  105. package/src/types/interface/api/type-message/response.ts +6 -0
  106. package/src/types/interface/index.ts +2 -0
  107. package/src/types/interface/models/index.ts +4 -0
  108. package/src/types/interface/models/link.dto.ts +117 -0
  109. package/src/types/interface/models/organization.dto.ts +21 -0
  110. package/src/types/interface/models/project.dto.ts +16 -0
  111. package/src/types/interface/models/user.dto.ts +19 -0
  112. package/src/types/tests/link-enums.spec.ts +46 -0
  113. package/src/utils/enum.utils.ts +1 -0
  114. package/src/utils/error.utils.ts +30 -0
  115. package/src/utils/index.ts +3 -0
  116. package/src/utils/link-slug.utils.ts +10 -0
  117. package/tsconfig.check.json +15 -0
  118. package/tsconfig.json +36 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./abyss.admin.response"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC"}
@@ -0,0 +1,6 @@
1
+ import { Code, ErrorType } from '../../../enum';
2
+ export interface IApiError {
3
+ code: Code;
4
+ type: ErrorType;
5
+ message?: string;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=api-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-error.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/type-message/api-error.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export interface BasePaginate<T> {
2
+ maxPages: number;
3
+ currentPage: number;
4
+ data: T[];
5
+ totalItems: number;
6
+ }
7
+ export interface QueryPaginate {
8
+ page?: number;
9
+ limit?: number;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=base-paginate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-paginate.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/type-message/base-paginate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { IApiError } from './api-error';
2
+ export interface IResponse<T> {
3
+ data: T;
4
+ error?: IApiError | Error;
5
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/type-message/response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from './models';
2
+ export * from './api';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./models"), exports);
18
+ __exportStar(require("./api"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/interface/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,wCAAsB"}
@@ -0,0 +1,4 @@
1
+ export * from './user.dto';
2
+ export * from './organization.dto';
3
+ export * from './project.dto';
4
+ export * from './link.dto';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./user.dto"), exports);
18
+ __exportStar(require("./organization.dto"), exports);
19
+ __exportStar(require("./project.dto"), exports);
20
+ __exportStar(require("./link.dto"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/interface/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,qDAAmC;AACnC,gDAA8B;AAC9B,6CAA2B"}
@@ -0,0 +1,91 @@
1
+ import { LinkKind, LinkResourceProduct, LinkVisitSource } from '../../enum/link.enum';
2
+ import { IOrganization } from './organization.dto';
3
+ import { IProject } from './project.dto';
4
+ import { IUser } from './user.dto';
5
+ export interface ILinkOrigin {
6
+ service: LinkResourceProduct;
7
+ resourceType: string;
8
+ resourceId: string;
9
+ }
10
+ export interface ILink {
11
+ id: string;
12
+ kind: LinkKind;
13
+ slug: string | null;
14
+ slugKey: string | null;
15
+ prefix: string | null;
16
+ code: string | null;
17
+ token: string | null;
18
+ targetUrl: string;
19
+ title: string | null;
20
+ description: string | null;
21
+ userId: string | null;
22
+ projectId: string | null;
23
+ organizationId: string | null;
24
+ createdByUserId: string | null;
25
+ originService: LinkResourceProduct | null;
26
+ originResourceType: string | null;
27
+ originResourceId: string | null;
28
+ isActive: boolean;
29
+ expiresAt: Date | null;
30
+ maxClicks: number | null;
31
+ passwordHash: string | null;
32
+ forwardCampaignParams: boolean;
33
+ isProtected: boolean;
34
+ protectedAt: Date | null;
35
+ protectedByAdminId: string | null;
36
+ clickCount: number;
37
+ uniqueClickCount: number;
38
+ lastVisitedAt: Date | null;
39
+ createdAt?: Date;
40
+ updatedAt?: Date;
41
+ user?: IUser | null;
42
+ project?: IProject | null;
43
+ organization?: IOrganization | null;
44
+ }
45
+ export interface ILinkVisit {
46
+ id: string;
47
+ linkId: string;
48
+ visitedAt: Date;
49
+ source: LinkVisitSource;
50
+ visitorHash: string;
51
+ isBot: boolean;
52
+ isFirstOfDay: boolean;
53
+ country: string | null;
54
+ city: string | null;
55
+ device: string | null;
56
+ browser: string | null;
57
+ os: string | null;
58
+ language: string | null;
59
+ refererDomain: string | null;
60
+ utmSource: string | null;
61
+ utmMedium: string | null;
62
+ utmCampaign: string | null;
63
+ utmTerm: string | null;
64
+ utmContent: string | null;
65
+ }
66
+ export interface ILinkBreakdowns {
67
+ countries: Record<string, number>;
68
+ cities: Record<string, number>;
69
+ devices: Record<string, number>;
70
+ browsers: Record<string, number>;
71
+ oses: Record<string, number>;
72
+ languages: Record<string, number>;
73
+ refererDomains: Record<string, number>;
74
+ utmSources: Record<string, number>;
75
+ utmMediums: Record<string, number>;
76
+ utmCampaigns: Record<string, number>;
77
+ }
78
+ export interface ILinkDailyStats extends ILinkBreakdowns {
79
+ linkId: string;
80
+ day: string;
81
+ visits: number;
82
+ uniqueVisitors: number;
83
+ botVisits: number;
84
+ }
85
+ export interface ILinkStats extends ILinkBreakdowns {
86
+ visits: number;
87
+ uniqueVisitors: number;
88
+ botVisits: number;
89
+ lastVisitedAt: Date | null;
90
+ daily: ILinkDailyStats[];
91
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=link.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/link.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { IProject } from './project.dto';
2
+ export interface IOrganization {
3
+ id?: string;
4
+ name: string;
5
+ slug: string;
6
+ kind?: 'standard' | 'family';
7
+ kindSyncedAt?: string | null;
8
+ updatedAt?: Date;
9
+ createdAt?: Date;
10
+ projects?: IProject[];
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=organization.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/organization.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { IOrganization } from './organization.dto';
2
+ import { IUser } from './user.dto';
3
+ export interface IProject {
4
+ id?: string;
5
+ name: string;
6
+ createdByUserId: string | null;
7
+ organizationId: string;
8
+ updatedAt?: Date;
9
+ createdAt?: Date;
10
+ organization?: IOrganization;
11
+ user?: IUser;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=project.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/project.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { IProject } from './project.dto';
2
+ export interface IUser {
3
+ id?: string;
4
+ isAdmin: boolean;
5
+ personalApiKeyLookupHash?: string | null;
6
+ personalApiKeyRevokedAt?: Date | null;
7
+ accountDeletedAt?: Date | null;
8
+ updatedAt?: Date;
9
+ createdAt?: Date;
10
+ projects?: IProject[];
11
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=user.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.dto.js","sourceRoot":"","sources":["../../../../src/types/interface/models/user.dto.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type ValueOf<T> = T[keyof T];
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=enum.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enum.utils.js","sourceRoot":"","sources":["../../src/utils/enum.utils.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { Code, ErrorType } from '../types';
2
+ type ErrorParams = {
3
+ code: Code;
4
+ type: ErrorType;
5
+ message?: string;
6
+ };
7
+ export declare class ServiceException extends Error {
8
+ private readonly code;
9
+ private readonly type;
10
+ getCode(): Code;
11
+ getType(): ErrorType;
12
+ constructor(params: ErrorParams);
13
+ }
14
+ export declare const handleError: (error: Error | ErrorParams, _params?: ErrorParams) => Error;
15
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleError = exports.ServiceException = void 0;
4
+ class ServiceException extends Error {
5
+ getCode() {
6
+ return this.code;
7
+ }
8
+ getType() {
9
+ return this.type;
10
+ }
11
+ constructor(params) {
12
+ super(params.message);
13
+ this.code = params.code;
14
+ this.type = params.type;
15
+ }
16
+ }
17
+ exports.ServiceException = ServiceException;
18
+ const handleError = (error, _params) => {
19
+ if (error instanceof Error) {
20
+ return error;
21
+ }
22
+ return new ServiceException(error);
23
+ };
24
+ exports.handleError = handleError;
25
+ //# sourceMappingURL=error.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.utils.js","sourceRoot":"","sources":["../../src/utils/error.utils.ts"],"names":[],"mappings":";;;AAIA,MAAa,gBAAiB,SAAQ,KAAK;IAKzC,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,YAAY,MAAmB;QAC7B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF;AAlBD,4CAkBC;AAEM,MAAM,WAAW,GAAG,CAAC,KAA0B,EAAE,OAAqB,EAAS,EAAE;IACtF,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC,CAAC;AALW,QAAA,WAAW,eAKtB"}
@@ -0,0 +1,3 @@
1
+ export * from './error.utils';
2
+ export * from './enum.utils';
3
+ export * from './link-slug.utils';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./error.utils"), exports);
18
+ __exportStar(require("./enum.utils"), exports);
19
+ __exportStar(require("./link-slug.utils"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,+CAA6B;AAC7B,oDAAkC"}
@@ -0,0 +1 @@
1
+ export declare const isForbiddenLinkSlug: (slug: string) => boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isForbiddenLinkSlug = void 0;
4
+ const link_constants_1 = require("../constants/link.constants");
5
+ const isForbiddenLinkSlug = (slug) => {
6
+ const key = slug.toLowerCase();
7
+ return (link_constants_1.LINK_FORBIDDEN_SLUGS.includes(key) ||
8
+ link_constants_1.LINK_FORBIDDEN_SLUG_PREFIXES.some((prefix) => key.startsWith(prefix)));
9
+ };
10
+ exports.isForbiddenLinkSlug = isForbiddenLinkSlug;
11
+ //# sourceMappingURL=link-slug.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-slug.utils.js","sourceRoot":"","sources":["../../src/utils/link-slug.utils.ts"],"names":[],"mappings":";;;AAAA,gEAAiG;AAG1F,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAW,EAAE;IAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC/B,OAAO,CACL,qCAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC;QAClC,6CAA4B,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CACtE,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B"}
@@ -0,0 +1,9 @@
1
+ /** @type {import('jest').Config} */
2
+ module.exports = {
3
+ testEnvironment: 'node',
4
+ transform: {
5
+ '^.+\\.tsx?$': 'ts-jest',
6
+ },
7
+ testMatch: ['**/tests/**/*.spec.ts'],
8
+ modulePathIgnorePatterns: ['dist'],
9
+ };
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@abyss-project/link",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Core package to interact with AbyssLink",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://gitlab.com/abyss-group/abyss-link.git"
10
+ },
11
+ "keywords": [],
12
+ "author": "scylla",
13
+ "license": "ISC",
14
+ "engines": {
15
+ "node": ">=19.8"
16
+ },
17
+ "dependencies": {
18
+ "axios": "^1.6.0",
19
+ "axios-retry": "^4.5.0",
20
+ "date-fns": "^2.30.0",
21
+ "dayjs": "^1.10.7",
22
+ "jsonwebtoken": "^8.5.1",
23
+ "reflect-metadata": "^0.1.13",
24
+ "ts-node": "^10.4.0",
25
+ "ts-node-dev": "^1.1.1",
26
+ "uuid": "^8.3.2"
27
+ },
28
+ "devDependencies": {
29
+ "@types/express-serve-static-core": "^4.19.6",
30
+ "@types/jest": "^29.5.14",
31
+ "@types/jsonwebtoken": "^8.5.0",
32
+ "@types/node": "^20.11.0",
33
+ "@types/uuid": "^8.3.0",
34
+ "@typescript-eslint/eslint-plugin": "8.71.0",
35
+ "@typescript-eslint/parser": "8.71.0",
36
+ "eslint": "^8.57.1",
37
+ "eslint-config-airbnb-base": "^14.2.1",
38
+ "eslint-config-prettier": "^8.3.0",
39
+ "eslint-config-standard": "^16.0.3",
40
+ "eslint-plugin-filenames-simple": "^0.7.0",
41
+ "eslint-plugin-import": "^2.23.4",
42
+ "eslint-plugin-node": "^11.1.0",
43
+ "eslint-plugin-prettier": "^3.4.0",
44
+ "eslint-plugin-promise": "^5.1.0",
45
+ "jest": "^29.7.0",
46
+ "prettier": "2.3.1",
47
+ "ts-jest": "^29.4.15",
48
+ "tsc-watch": "^4.6.2",
49
+ "typescript": "5.9.3"
50
+ },
51
+ "scripts": {
52
+ "lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
53
+ "lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
54
+ "tsc": "tsc",
55
+ "build": "tsc",
56
+ "test": "jest",
57
+ "dev": "tsc --watch"
58
+ }
6
59
  }
@@ -0,0 +1,39 @@
1
+ import {
2
+ AbyssLinkCore,
3
+ IActivateUserServiceAbyssAdminBody,
4
+ IActivateUserServiceAbyssAdminResponse,
5
+ ISyncOrganizationAbyssAdminBody,
6
+ ISyncOrganizationAbyssAdminResponse,
7
+ ISyncProjectAbyssAdminBody,
8
+ ISyncProjectAbyssAdminResponse,
9
+ } from '..';
10
+
11
+ export const activateUserServiceAbyssAdmin = async (
12
+ body: IActivateUserServiceAbyssAdminBody,
13
+ ): Promise<IActivateUserServiceAbyssAdminResponse> => {
14
+ return (
15
+ await AbyssLinkCore.axios.post<IActivateUserServiceAbyssAdminResponse>(
16
+ `abyss/admin/user/activate-service`,
17
+ body,
18
+ )
19
+ ).data;
20
+ };
21
+
22
+ export const syncOrganizationAbyssAdmin = async (
23
+ body: ISyncOrganizationAbyssAdminBody,
24
+ ): Promise<ISyncOrganizationAbyssAdminResponse> => {
25
+ return (
26
+ await AbyssLinkCore.axios.post<ISyncOrganizationAbyssAdminResponse>(
27
+ `abyss/admin/organization/sync`,
28
+ body,
29
+ )
30
+ ).data;
31
+ };
32
+
33
+ export const syncProjectAbyssAdmin = async (
34
+ body: ISyncProjectAbyssAdminBody,
35
+ ): Promise<ISyncProjectAbyssAdminResponse> => {
36
+ return (
37
+ await AbyssLinkCore.axios.post<ISyncProjectAbyssAdminResponse>(`abyss/admin/project/sync`, body)
38
+ ).data;
39
+ };
@@ -0,0 +1 @@
1
+ export * from './abyss.admin.api';
@@ -0,0 +1 @@
1
+ export * from './link.constants';
@@ -0,0 +1,49 @@
1
+ import { LinkResourceProduct } from '../types/enum/link.enum';
2
+
3
+ /** Products that own a RESOURCE address. Spotlight only receives campaign tokens, which have no Link address. */
4
+ export type LinkPrefixedProduct = Exclude<LinkResourceProduct, LinkResourceProduct.SPOTLIGHT>;
5
+
6
+ /** First segment of a RESOURCE address, `<host>/<prefix>/<code>` (spec §3.5). Compared in lowercase (R10). */
7
+ export const LINK_RESOURCE_PREFIXES: Readonly<Record<LinkPrefixedProduct, string>> = {
8
+ [LinkResourceProduct.BEAM]: 'b',
9
+ [LinkResourceProduct.ATLAS]: 'a',
10
+ [LinkResourceProduct.DRAW]: 'd',
11
+ [LinkResourceProduct.RETROSPECTIVE]: 'r',
12
+ [LinkResourceProduct.FORM]: 'f',
13
+ [LinkResourceProduct.EXTRACT]: 'e',
14
+ [LinkResourceProduct.CLOUD]: 'c',
15
+ [LinkResourceProduct.MEMORIES]: 'm',
16
+ };
17
+
18
+ /** A SHORTENED slug starting with one of these (lowercase) is refused. */
19
+ export const LINK_FORBIDDEN_SLUG_PREFIXES: readonly string[] = ['_', 'abyss'];
20
+
21
+ /** SHORTENED slugs refused at manual creation, in lowercase: every resource prefix and the host's own paths. */
22
+ export const LINK_FORBIDDEN_SLUGS: readonly string[] = [
23
+ ...Object.values(LINK_RESOURCE_PREFIXES),
24
+ 'api',
25
+ 'assets',
26
+ 'static',
27
+ 'health',
28
+ 'admin',
29
+ 'login',
30
+ 'favicon.ico',
31
+ 'robots.txt',
32
+ '.well-known',
33
+ ];
34
+
35
+ export const MIN_LINK_SLUG_LENGTH = 3;
36
+ export const MAX_LINK_SLUG_LENGTH = 50;
37
+ export const LINK_SLUG_PATTERN = /^[a-zA-Z0-9_-]{3,50}$/;
38
+
39
+ export const MIN_LINK_PASSWORD_LENGTH = 4;
40
+ export const MAX_LINK_PASSWORD_LENGTH = 128;
41
+
42
+ /** Base62 code of a RESOURCE address, compared exactly (R10). */
43
+ export const LINK_RESOURCE_CODE_LENGTH = 10;
44
+ /** Base62 campaign token. */
45
+ export const LINK_CAMPAIGN_TOKEN_LENGTH = 12;
46
+ export const LINK_CAMPAIGN_TOKENS_PER_PROJECT = 50;
47
+
48
+ /** Raw visits are kept this long (O2); daily aggregates live as long as the link. */
49
+ export const LINK_VISIT_RETENTION_DAYS = 90;