@btst/plugin-affiliate 0.0.0-stage → 1.0.0-beta.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 (79) hide show
  1. package/LICENSE.md +17 -0
  2. package/dist/api/getters.cjs +182 -0
  3. package/dist/api/getters.mjs +166 -0
  4. package/dist/api/index.cjs +49 -0
  5. package/dist/api/index.d.cts +975 -0
  6. package/dist/api/index.d.mts +975 -0
  7. package/dist/api/index.d.ts +975 -0
  8. package/dist/api/index.mjs +7 -0
  9. package/dist/api/mutations.cjs +362 -0
  10. package/dist/api/mutations.mjs +352 -0
  11. package/dist/api/operations.cjs +328 -0
  12. package/dist/api/operations.mjs +326 -0
  13. package/dist/api/plugin.cjs +146 -0
  14. package/dist/api/plugin.mjs +144 -0
  15. package/dist/attribution.cjs +92 -0
  16. package/dist/attribution.d.cts +20 -0
  17. package/dist/attribution.d.mts +20 -0
  18. package/dist/attribution.d.ts +20 -0
  19. package/dist/attribution.mjs +82 -0
  20. package/dist/client/components/index.cjs +12 -0
  21. package/dist/client/components/index.d.cts +13 -0
  22. package/dist/client/components/index.d.mts +13 -0
  23. package/dist/client/components/index.d.ts +13 -0
  24. package/dist/client/components/index.mjs +1 -0
  25. package/dist/client/components/pages/affiliate-apply-page.internal.cjs +59 -0
  26. package/dist/client/components/pages/affiliate-apply-page.internal.mjs +57 -0
  27. package/dist/client/components/pages/affiliate-detail-page.internal.cjs +112 -0
  28. package/dist/client/components/pages/affiliate-detail-page.internal.mjs +110 -0
  29. package/dist/client/components/pages/affiliate-portal-page.internal.cjs +252 -0
  30. package/dist/client/components/pages/affiliate-portal-page.internal.mjs +250 -0
  31. package/dist/client/components/pages/affiliates-page.internal.cjs +160 -0
  32. package/dist/client/components/pages/affiliates-page.internal.mjs +158 -0
  33. package/dist/client/components/pages/commissions-page.internal.cjs +151 -0
  34. package/dist/client/components/pages/commissions-page.internal.mjs +149 -0
  35. package/dist/client/components/pages/payouts-page.internal.cjs +230 -0
  36. package/dist/client/components/pages/payouts-page.internal.mjs +228 -0
  37. package/dist/client/components/pages.cjs +145 -0
  38. package/dist/client/components/pages.mjs +138 -0
  39. package/dist/client/components/shared.cjs +331 -0
  40. package/dist/client/components/shared.mjs +316 -0
  41. package/dist/client/constants.cjs +5 -0
  42. package/dist/client/constants.mjs +3 -0
  43. package/dist/client/hooks/index.cjs +77 -0
  44. package/dist/client/hooks/index.d.cts +39 -0
  45. package/dist/client/hooks/index.d.mts +39 -0
  46. package/dist/client/hooks/index.d.ts +39 -0
  47. package/dist/client/hooks/index.mjs +61 -0
  48. package/dist/client/index.cjs +7 -0
  49. package/dist/client/index.d.cts +110 -0
  50. package/dist/client/index.d.mts +110 -0
  51. package/dist/client/index.d.ts +110 -0
  52. package/dist/client/index.mjs +1 -0
  53. package/dist/client/plugin.cjs +77 -0
  54. package/dist/client/plugin.mjs +75 -0
  55. package/dist/client.css +311 -0
  56. package/dist/commission.cjs +24 -0
  57. package/dist/commission.mjs +22 -0
  58. package/dist/db.cjs +74 -0
  59. package/dist/db.mjs +72 -0
  60. package/dist/permissions.cjs +53 -0
  61. package/dist/permissions.d.cts +78 -0
  62. package/dist/permissions.d.mts +78 -0
  63. package/dist/permissions.d.ts +78 -0
  64. package/dist/permissions.mjs +51 -0
  65. package/dist/query-keys.cjs +152 -0
  66. package/dist/query-keys.d.cts +394 -0
  67. package/dist/query-keys.d.mts +394 -0
  68. package/dist/query-keys.d.ts +394 -0
  69. package/dist/query-keys.mjs +149 -0
  70. package/dist/schemas.cjs +95 -0
  71. package/dist/schemas.mjs +77 -0
  72. package/dist/style.css +313 -0
  73. package/dist/types.cjs +2 -0
  74. package/dist/types.d.cts +176 -0
  75. package/dist/types.d.mts +176 -0
  76. package/dist/types.d.ts +176 -0
  77. package/dist/types.mjs +1 -0
  78. package/package.json +159 -3
  79. package/README.md +0 -3
@@ -0,0 +1,78 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Administrative permissions are separate from identity-scoped portal access. */
5
+ declare const affiliatePermissions: _btst_stack_authorization.PermissionCatalog<"affiliate", {
6
+ readonly affiliate: {
7
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ scope: z.ZodLiteral<"collection">;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ scope: z.ZodLiteral<"record">;
11
+ affiliateId: z.ZodString;
12
+ }, z.core.$strip>], "scope">>;
13
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
14
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
15
+ affiliateId: z.ZodString;
16
+ userId: z.ZodString;
17
+ status: z.ZodEnum<{
18
+ pending: "pending";
19
+ approved: "approved";
20
+ suspended: "suspended";
21
+ }>;
22
+ }, z.core.$strip>>;
23
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
24
+ affiliateId: z.ZodString;
25
+ userId: z.ZodString;
26
+ status: z.ZodEnum<{
27
+ pending: "pending";
28
+ approved: "approved";
29
+ suspended: "suspended";
30
+ }>;
31
+ }, z.core.$strip>>;
32
+ };
33
+ readonly application: {
34
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
35
+ };
36
+ readonly portal: {
37
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
38
+ readonly update: _btst_stack_authorization.PermissionSeed<undefined>;
39
+ };
40
+ readonly tracking: {
41
+ readonly track: _btst_stack_authorization.PermissionSeed<undefined>;
42
+ };
43
+ readonly conversion: {
44
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
45
+ };
46
+ readonly commission: {
47
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
48
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
49
+ commissionId: z.ZodString;
50
+ affiliateId: z.ZodString;
51
+ status: z.ZodEnum<{
52
+ pending: "pending";
53
+ approved: "approved";
54
+ paid: "paid";
55
+ voided: "voided";
56
+ }>;
57
+ }, z.core.$strip>>;
58
+ };
59
+ readonly payout: {
60
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
61
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
62
+ affiliateId: z.ZodString;
63
+ currency: z.ZodString;
64
+ }, z.core.$strip>>;
65
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
66
+ payoutId: z.ZodString;
67
+ affiliateId: z.ZodString;
68
+ status: z.ZodEnum<{
69
+ pending: "pending";
70
+ sent: "sent";
71
+ failed: "failed";
72
+ }>;
73
+ }, z.core.$strip>>;
74
+ readonly export: _btst_stack_authorization.PermissionSeed<undefined>;
75
+ };
76
+ }>;
77
+
78
+ export { affiliatePermissions };
@@ -0,0 +1,78 @@
1
+ import * as _btst_stack_authorization from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ /** Administrative permissions are separate from identity-scoped portal access. */
5
+ declare const affiliatePermissions: _btst_stack_authorization.PermissionCatalog<"affiliate", {
6
+ readonly affiliate: {
7
+ readonly read: _btst_stack_authorization.PermissionSeed<z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ scope: z.ZodLiteral<"collection">;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ scope: z.ZodLiteral<"record">;
11
+ affiliateId: z.ZodString;
12
+ }, z.core.$strip>], "scope">>;
13
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
14
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
15
+ affiliateId: z.ZodString;
16
+ userId: z.ZodString;
17
+ status: z.ZodEnum<{
18
+ pending: "pending";
19
+ approved: "approved";
20
+ suspended: "suspended";
21
+ }>;
22
+ }, z.core.$strip>>;
23
+ readonly delete: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
24
+ affiliateId: z.ZodString;
25
+ userId: z.ZodString;
26
+ status: z.ZodEnum<{
27
+ pending: "pending";
28
+ approved: "approved";
29
+ suspended: "suspended";
30
+ }>;
31
+ }, z.core.$strip>>;
32
+ };
33
+ readonly application: {
34
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
35
+ };
36
+ readonly portal: {
37
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
38
+ readonly update: _btst_stack_authorization.PermissionSeed<undefined>;
39
+ };
40
+ readonly tracking: {
41
+ readonly track: _btst_stack_authorization.PermissionSeed<undefined>;
42
+ };
43
+ readonly conversion: {
44
+ readonly create: _btst_stack_authorization.PermissionSeed<undefined>;
45
+ };
46
+ readonly commission: {
47
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
48
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
49
+ commissionId: z.ZodString;
50
+ affiliateId: z.ZodString;
51
+ status: z.ZodEnum<{
52
+ pending: "pending";
53
+ approved: "approved";
54
+ paid: "paid";
55
+ voided: "voided";
56
+ }>;
57
+ }, z.core.$strip>>;
58
+ };
59
+ readonly payout: {
60
+ readonly read: _btst_stack_authorization.PermissionSeed<undefined>;
61
+ readonly create: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
62
+ affiliateId: z.ZodString;
63
+ currency: z.ZodString;
64
+ }, z.core.$strip>>;
65
+ readonly update: _btst_stack_authorization.PermissionSeed<z.ZodObject<{
66
+ payoutId: z.ZodString;
67
+ affiliateId: z.ZodString;
68
+ status: z.ZodEnum<{
69
+ pending: "pending";
70
+ sent: "sent";
71
+ failed: "failed";
72
+ }>;
73
+ }, z.core.$strip>>;
74
+ readonly export: _btst_stack_authorization.PermissionSeed<undefined>;
75
+ };
76
+ }>;
77
+
78
+ export { affiliatePermissions };
@@ -0,0 +1,51 @@
1
+ import { definePermissions, permission } from '@btst/stack/authorization';
2
+ import { z } from 'zod';
3
+
4
+ const affiliateFacts = z.object({
5
+ affiliateId: z.string(),
6
+ userId: z.string(),
7
+ status: z.enum(["pending", "approved", "suspended"])
8
+ });
9
+ const affiliatePermissions = definePermissions("affiliate", {
10
+ affiliate: {
11
+ read: permission(
12
+ z.discriminatedUnion("scope", [
13
+ z.object({ scope: z.literal("collection") }),
14
+ z.object({ scope: z.literal("record"), affiliateId: z.string() })
15
+ ])
16
+ ),
17
+ create: permission(),
18
+ update: permission(affiliateFacts),
19
+ delete: permission(affiliateFacts)
20
+ },
21
+ application: { create: permission() },
22
+ portal: { read: permission(), update: permission() },
23
+ tracking: { track: permission() },
24
+ conversion: { create: permission() },
25
+ commission: {
26
+ read: permission(),
27
+ update: permission(
28
+ z.object({
29
+ commissionId: z.string(),
30
+ affiliateId: z.string(),
31
+ status: z.enum(["pending", "approved", "paid", "voided"])
32
+ })
33
+ )
34
+ },
35
+ payout: {
36
+ read: permission(),
37
+ create: permission(
38
+ z.object({ affiliateId: z.string(), currency: z.string() })
39
+ ),
40
+ update: permission(
41
+ z.object({
42
+ payoutId: z.string(),
43
+ affiliateId: z.string(),
44
+ status: z.enum(["pending", "sent", "failed"])
45
+ })
46
+ ),
47
+ export: permission()
48
+ }
49
+ });
50
+
51
+ export { affiliatePermissions };
@@ -0,0 +1,152 @@
1
+ 'use strict';
2
+
3
+ const client = require('@btst/stack/plugins/client');
4
+
5
+ const invalidates = [
6
+ "affiliates",
7
+ "affiliatePortal",
8
+ "affiliateCommissions",
9
+ "affiliatePayouts"
10
+ ];
11
+ const affiliateResources = {
12
+ affiliates: {
13
+ queries: {
14
+ list: {
15
+ path: "/affiliate/affiliates",
16
+ query: (params = {}, _partition) => ({
17
+ ...params
18
+ }),
19
+ select: (data) => data
20
+ },
21
+ detail: {
22
+ path: "/affiliate/affiliates/:id",
23
+ params: (id, _partition) => ({ id }),
24
+ select: (data) => data
25
+ }
26
+ },
27
+ mutations: {
28
+ create: {
29
+ path: "@post/affiliate/affiliates",
30
+ method: "POST",
31
+ input: (body) => ({ body }),
32
+ select: (data) => data,
33
+ invalidates,
34
+ refresh: false
35
+ },
36
+ update: {
37
+ path: "@put/affiliate/affiliates/:id",
38
+ method: "PUT",
39
+ input: ({ id, data }) => ({
40
+ params: { id },
41
+ body: data
42
+ }),
43
+ select: (data) => data,
44
+ invalidates,
45
+ refresh: false
46
+ },
47
+ delete: {
48
+ path: "@delete/affiliate/affiliates/:id",
49
+ method: "DELETE",
50
+ input: (id) => ({ params: { id } }),
51
+ invalidates,
52
+ refresh: false
53
+ }
54
+ }
55
+ },
56
+ affiliatePortal: {
57
+ queries: {
58
+ detail: {
59
+ path: "/affiliate/portal",
60
+ key: (partition) => [partition],
61
+ select: (data) => data
62
+ }
63
+ },
64
+ mutations: {
65
+ apply: {
66
+ path: "@post/affiliate/apply",
67
+ method: "POST",
68
+ input: (body) => ({ body }),
69
+ select: (data) => data,
70
+ invalidates,
71
+ refresh: false
72
+ },
73
+ update: {
74
+ path: "@put/affiliate/portal",
75
+ method: "PUT",
76
+ input: (body) => ({ body }),
77
+ select: (data) => data,
78
+ invalidates,
79
+ refresh: false
80
+ }
81
+ }
82
+ },
83
+ affiliateCommissions: {
84
+ queries: {
85
+ list: {
86
+ path: "/affiliate/commissions",
87
+ query: (params = {}, _partition) => ({
88
+ ...params
89
+ }),
90
+ select: (data) => data
91
+ }
92
+ },
93
+ mutations: {
94
+ update: {
95
+ path: "@put/affiliate/commissions/:id",
96
+ method: "PUT",
97
+ input: ({
98
+ id,
99
+ status
100
+ }) => ({ params: { id }, body: { status } }),
101
+ select: (data) => data,
102
+ invalidates,
103
+ refresh: false
104
+ }
105
+ }
106
+ },
107
+ affiliatePayouts: {
108
+ queries: {
109
+ list: {
110
+ path: "/affiliate/payouts",
111
+ query: (params = {}, _partition) => ({
112
+ ...params
113
+ }),
114
+ select: (data) => data
115
+ },
116
+ export: {
117
+ path: "/affiliate/payouts/export",
118
+ query: (params = {}, _partition) => ({
119
+ ...params
120
+ }),
121
+ select: (data) => data
122
+ }
123
+ },
124
+ mutations: {
125
+ create: {
126
+ path: "@post/affiliate/payouts",
127
+ method: "POST",
128
+ input: (body) => ({ body }),
129
+ select: (data) => data,
130
+ invalidates,
131
+ refresh: false
132
+ },
133
+ update: {
134
+ path: "@put/affiliate/payouts/:id",
135
+ method: "PUT",
136
+ input: ({
137
+ id,
138
+ ...body
139
+ }) => ({ params: { id }, body }),
140
+ select: (data) => data,
141
+ invalidates,
142
+ refresh: false
143
+ }
144
+ }
145
+ }
146
+ };
147
+ function createAffiliateQueryKeys(client$1, headers) {
148
+ return client.createResourceQueryKeys(client$1, affiliateResources, headers);
149
+ }
150
+
151
+ exports.affiliateResources = affiliateResources;
152
+ exports.createAffiliateQueryKeys = createAffiliateQueryKeys;