@fayz-ai/plugin-courses 0.9.1 → 0.10.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.
@@ -0,0 +1,34 @@
1
+ import { type ConnectorDefinition, type ConnectorField, type ConnectorSetting } from '@fayz-ai/core';
2
+ export declare const KIWIFY_CONNECTOR_ID = "kiwify";
3
+ /**
4
+ * What authorizes the connection — all three come from the same Kiwify screen
5
+ * ("Apps → API → Criar API Key"), and none can be inferred from the others.
6
+ *
7
+ * Two of them are one credential. `client_id` and `client_secret` are issued
8
+ * together and the id is useless to anyone without the secret, so the id
9
+ * carries `secret: true`: it goes to the vault WITH its other half instead of
10
+ * falling through to this file, which is how half a credential ends up in a
11
+ * pool table. Only the secret is masked — a merchant has to be able to check
12
+ * they pasted the right id.
13
+ *
14
+ * The account id is genuinely not a credential. It is the
15
+ * `x-kiwify-account-id` header that says WHICH account the token is spent on,
16
+ * so it stays on the connection row where an operator can read it back.
17
+ *
18
+ * No `providerInstall`: Kiwify's docs name the path ("Apps → API") and publish
19
+ * no URL for it, and a door that opens somewhere wrong is worse than a
20
+ * placeholder that says where to look.
21
+ */
22
+ export declare const KIWIFY_FIELDS: ConnectorField[];
23
+ /** Kiwify's own 90-day ceiling on a sales query, in one place. */
24
+ export declare const KIWIFY_MAX_WINDOW_DAYS = 90;
25
+ /**
26
+ * How the live feed BEHAVES — chosen after the account is linked, changed
27
+ * whenever the tenant likes.
28
+ *
29
+ * None of it authorizes anything, which is why none of it is a field: a school
30
+ * that decides to stop auto-enrolling has not re-authorized Kiwify.
31
+ */
32
+ export declare const KIWIFY_SETTINGS: ConnectorSetting[];
33
+ export declare const kiwifyConnectorDef: ConnectorDefinition;
34
+ //# sourceMappingURL=connectorDef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectorDef.d.ts","sourceRoot":"","sources":["../../../src/integrations/kiwify/connectorDef.tsx"],"names":[],"mappings":"AA2BA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAA;AAWtB,eAAO,MAAM,mBAAmB,WAAW,CAAA;AAE3C;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,EAAE,cAAc,EAIzC,CAAA;AAED,kEAAkE;AAClE,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,gBAAgB,EAwC7C,CAAA;AAuND,eAAO,MAAM,kBAAkB,EAAE,mBAkGhC,CAAA"}
@@ -0,0 +1,58 @@
1
+ /** The edge function that holds every Kiwify call this connector makes. */
2
+ export declare const KIWIFY_FUNCTION = "kiwify-courses-sync";
3
+ /** `plg_courses_orders.external_source` for everything this connector writes. */
4
+ export declare const KIWIFY_SOURCE = "kiwify";
5
+ export interface KiwifyProduct {
6
+ id: string;
7
+ name: string;
8
+ }
9
+ export interface KiwifyImportResult {
10
+ fetched: number;
11
+ imported: number;
12
+ updated: number;
13
+ duplicates: number;
14
+ unmapped: number;
15
+ enrolled: number;
16
+ }
17
+ /** A course here, and the Kiwify product it is — the tenant's own de-para. */
18
+ export interface CourseMapping {
19
+ courseId: string;
20
+ title: string;
21
+ externalId: string | null;
22
+ }
23
+ /**
24
+ * Ask the provider who we are.
25
+ *
26
+ * Not `testConnection`, and not on the ConnectorDefinition: that verb runs
27
+ * BEFORE saving, with the form's values, and this connector's secret never
28
+ * reaches this code — the hub correctly hides the button for exactly that
29
+ * reason. This runs AFTER the credential is placed, which is the only moment
30
+ * there is anything to test.
31
+ *
32
+ * What comes back is the account's name, which is the only answer a person can
33
+ * verify: "sim, é a minha conta" is a different statement from "a chamada não
34
+ * deu erro".
35
+ */
36
+ export declare function checkAccount(): Promise<{
37
+ ok: boolean;
38
+ message?: string;
39
+ }>;
40
+ /** The provider's catalogue, for the mapping panel. Never stored — read each time it is shown. */
41
+ export declare function listProducts(): Promise<KiwifyProduct[]>;
42
+ /** Pull a period of sales. The window is capped at Kiwify's own 90 days server-side. */
43
+ export declare function importSales(input: {
44
+ from: string;
45
+ to: string;
46
+ }): Promise<KiwifyImportResult>;
47
+ /**
48
+ * The de-para, read straight off the courses table.
49
+ *
50
+ * `external_id` is not on the `Course` domain type and is not going on it: it is
51
+ * a fact about an INTEGRATION, meaningless to a school that never sold on
52
+ * Kiwify, and putting it in the provider contract would make every consumer of
53
+ * `Course` carry a field only this panel reads.
54
+ */
55
+ export declare function listMappings(): Promise<CourseMapping[]>;
56
+ /** Point a course at a Kiwify product, or clear it. */
57
+ export declare function saveMapping(courseId: string, externalId: string | null): Promise<void>;
58
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../src/integrations/kiwify/data.ts"],"names":[],"mappings":"AAYA,2EAA2E;AAC3E,eAAO,MAAM,eAAe,wBAAwB,CAAA;AAEpD,iFAAiF;AACjF,eAAO,MAAM,aAAa,WAAW,CAAA;AAErC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAuCD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAEzE;AAED,kGAAkG;AAClG,wBAAgB,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAEvD;AAED,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE5F;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAkB7D;AAED,uDAAuD;AACvD,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5F"}
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4MrC,CAAA"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuMrC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/locales/pt-BR.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA4MvC,CAAA"}
1
+ {"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/locales/pt-BR.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAuMvC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"FinancialPage.d.ts","sourceRoot":"","sources":["../../src/views/FinancialPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,wBAAgB,aAAa,sBAmE5B;yBAnEe,aAAa"}
1
+ {"version":3,"file":"FinancialPage.d.ts","sourceRoot":"","sources":["../../src/views/FinancialPage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY9B,wBAAgB,aAAa,sBAgD5B;yBAhDe,aAAa"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "fayz": {
4
4
  "status": "preview"
5
5
  },
6
- "version": "0.9.1",
6
+ "version": "0.10.0",
7
7
  "description": "[experimental] Fayz SDK — courses admin management plugin",
8
8
  "type": "module",
9
9
  "sideEffects": false,
@@ -33,17 +33,18 @@
33
33
  "@dnd-kit/core": "^6.3.1",
34
34
  "@dnd-kit/sortable": "^10.0.0",
35
35
  "@dnd-kit/utilities": "^3.2.2",
36
- "@fayz-ai/core": "^0.10.0",
37
- "@fayz-ai/ui": "^0.10.0",
38
- "@fayz-ai/courses": "^0.10.0",
39
- "@fayz-ai/admin": "^0.10.0"
36
+ "@fayz-ai/core": "^0.11.0",
37
+ "@fayz-ai/ui": "^0.11.0",
38
+ "@fayz-ai/courses": "^0.11.0",
39
+ "@fayz-ai/admin": "^0.11.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^18.3.0",
43
43
  "react": "^18.3.0",
44
44
  "tsup": "^8.2.0",
45
45
  "typescript": "^5.5.0",
46
- "lucide-react": "^0.400.0"
46
+ "lucide-react": "^0.400.0",
47
+ "vitest": "^4.1.5"
47
48
  },
48
49
  "license": "MIT",
49
50
  "keywords": [
@@ -58,7 +59,9 @@
58
59
  "scripts": {
59
60
  "build": "tsup && tsc --emitDeclarationOnly --declaration --declarationMap --noEmit false",
60
61
  "dev": "tsup --watch",
61
- "typecheck": "tsc --noEmit",
62
- "clean": "rm -rf dist"
62
+ "typecheck": "tsc --noEmit -p tsconfig.test.json",
63
+ "clean": "rm -rf dist",
64
+ "test": "vitest run && pnpm run test:functions",
65
+ "test:functions": "node --test functions/_shared/*.test.mjs"
63
66
  }
64
67
  }
@@ -1,3 +0,0 @@
1
- import type { ConnectorDefinition } from '@fayz-ai/core';
2
- export declare function createStripeConnector(): ConnectorDefinition;
3
- //# sourceMappingURL=stripe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripe.d.ts","sourceRoot":"","sources":["../../src/connectors/stripe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAMxD,wBAAgB,qBAAqB,IAAI,mBAAmB,CA2B3D"}