@fntio/infra-client-plugin-sdk 0.0.0-stage → 0.2.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 (58) hide show
  1. package/LICENSE +93 -0
  2. package/README.md +279 -2
  3. package/dist/backend/context.d.ts +31 -0
  4. package/dist/backend/context.js +58 -0
  5. package/dist/backend/index.d.ts +9 -0
  6. package/dist/backend/index.js +26 -0
  7. package/dist/browser/client.d.ts +59 -0
  8. package/dist/browser/client.js +288 -0
  9. package/dist/browser/errors.d.ts +14 -0
  10. package/dist/browser/errors.js +32 -0
  11. package/dist/browser/http.d.ts +72 -0
  12. package/dist/browser/http.js +170 -0
  13. package/dist/browser/index.d.ts +11 -0
  14. package/dist/browser/index.js +28 -0
  15. package/dist/browser/theme-apply.d.ts +22 -0
  16. package/dist/browser/theme-apply.js +22 -0
  17. package/dist/contracts/access.d.ts +14 -0
  18. package/dist/contracts/access.js +41 -0
  19. package/dist/contracts/authorizer.d.ts +17 -0
  20. package/dist/contracts/authorizer.js +44 -0
  21. package/dist/contracts/canonical.d.ts +2 -0
  22. package/dist/contracts/canonical.js +21 -0
  23. package/dist/contracts/catalog.d.ts +37 -0
  24. package/dist/contracts/catalog.js +18 -0
  25. package/dist/contracts/discovery.d.ts +78 -0
  26. package/dist/contracts/discovery.js +48 -0
  27. package/dist/contracts/fields.d.ts +7 -0
  28. package/dist/contracts/fields.js +2 -0
  29. package/dist/contracts/manifest.d.ts +59 -0
  30. package/dist/contracts/manifest.js +19 -0
  31. package/dist/contracts/messages.d.ts +108 -0
  32. package/dist/contracts/messages.js +103 -0
  33. package/dist/contracts/paths.d.ts +20 -0
  34. package/dist/contracts/paths.js +49 -0
  35. package/dist/contracts/theme.d.ts +21 -0
  36. package/dist/contracts/theme.js +60 -0
  37. package/dist/contracts/transport.d.ts +14 -0
  38. package/dist/contracts/transport.js +10 -0
  39. package/dist/contracts/validate.d.ts +27 -0
  40. package/dist/contracts/validate.js +321 -0
  41. package/dist/fixtures/devHost.d.ts +57 -0
  42. package/dist/fixtures/devHost.js +91 -0
  43. package/dist/fixtures/fakeDocument.d.ts +12 -0
  44. package/dist/fixtures/fakeDocument.js +22 -0
  45. package/dist/fixtures/fakeWindows.d.ts +22 -0
  46. package/dist/fixtures/fakeWindows.js +46 -0
  47. package/dist/fixtures/index.d.ts +4 -0
  48. package/dist/fixtures/index.js +20 -0
  49. package/dist/fixtures/samples.d.ts +37 -0
  50. package/dist/fixtures/samples.js +220 -0
  51. package/dist/host/host.d.ts +47 -0
  52. package/dist/host/host.js +117 -0
  53. package/dist/host/index.d.ts +5 -0
  54. package/dist/host/index.js +22 -0
  55. package/dist/index.d.ts +10 -0
  56. package/dist/index.js +28 -0
  57. package/package.json +97 -4
  58. package/skills/build-infra-client-plugin/SKILL.md +61 -0
package/package.json CHANGED
@@ -1,6 +1,99 @@
1
1
  {
2
2
  "name": "@fntio/infra-client-plugin-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Contracts and runtime for infra-client customer plugins: manifest, catalog, discovery, the iframe SDK and host adapter, authorizer context, validators and test fixtures.",
5
+ "license": "Elastic-2.0",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/FNTIO/aws-infrastructure-client.git",
12
+ "directory": "packages/infra-client-plugin-sdk"
13
+ },
14
+ "homepage": "https://github.com/FNTIO/aws-infrastructure-client/wiki",
15
+ "bugs": {
16
+ "url": "https://github.com/FNTIO/aws-infrastructure-client/issues"
17
+ },
18
+ "main": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "exports": {
21
+ "./package.json": "./package.json",
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./browser": {
27
+ "types": "./dist/browser/index.d.ts",
28
+ "default": "./dist/browser/index.js"
29
+ },
30
+ "./host": {
31
+ "types": "./dist/host/index.d.ts",
32
+ "default": "./dist/host/index.js"
33
+ },
34
+ "./backend": {
35
+ "types": "./dist/backend/index.d.ts",
36
+ "default": "./dist/backend/index.js"
37
+ },
38
+ "./fixtures": {
39
+ "types": "./dist/fixtures/index.d.ts",
40
+ "default": "./dist/fixtures/index.js"
41
+ }
42
+ },
43
+ "typesVersions": {
44
+ "*": {
45
+ "browser": [
46
+ "dist/browser/index.d.ts"
47
+ ],
48
+ "host": [
49
+ "dist/host/index.d.ts"
50
+ ],
51
+ "backend": [
52
+ "dist/backend/index.d.ts"
53
+ ],
54
+ "fixtures": [
55
+ "dist/fixtures/index.d.ts"
56
+ ]
57
+ }
58
+ },
59
+ "files": [
60
+ "dist",
61
+ "skills",
62
+ "README.md"
63
+ ],
64
+ "sideEffects": false,
65
+ "engines": {
66
+ "node": ">=20"
67
+ },
68
+ "scripts": {
69
+ "build": "tsc -p tsconfig.build.json",
70
+ "prepack": "npm run build",
71
+ "test": "jest"
72
+ },
73
+ "jest": {
74
+ "testEnvironment": "node",
75
+ "roots": [
76
+ "<rootDir>/src"
77
+ ],
78
+ "testMatch": [
79
+ "**/*.test.ts"
80
+ ],
81
+ "transform": {
82
+ "^.+\\.tsx?$": [
83
+ "ts-jest",
84
+ {
85
+ "tsconfig": "<rootDir>/tsconfig.jest.json"
86
+ }
87
+ ]
88
+ },
89
+ "maxWorkers": "50%",
90
+ "workerIdleMemoryLimit": "2GB"
91
+ },
92
+ "devDependencies": {
93
+ "@types/jest": "^29.5.14",
94
+ "@types/node": "^20.19.43",
95
+ "jest": "^29.7.0",
96
+ "ts-jest": "^29.2.0",
97
+ "typescript": "^5.5.0"
98
+ }
99
+ }
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: build-infra-client-plugin
3
+ description: Build a customer plugin for an infra-client access portal — manifest, permissions, routes, a Lambda handler using the backend SDK, and a frontend using the browser SDK. Use when someone asks to add a plugin, a plugin page, or a plugin API to their portal.
4
+ ---
5
+
6
+ # Build an infra-client plugin
7
+
8
+ A plugin is a small app the portal hosts: a frontend in an iframe on the portal's own origin, and
9
+ Lambda routes behind the portal's shared authorizer. The portal handles sign-in, which accounts a
10
+ caller may use, theming and permissions. You write the business part.
11
+
12
+ **Before writing anything, read the installed package's own documentation** — `README.md` in
13
+ `@fntio/infra-client-plugin-sdk`, and the worked example in `@fntio/infra-client-plugin-example`. They
14
+ match the version installed in this project; this file does not restate their API, deliberately, so
15
+ there is one place to maintain.
16
+
17
+ ## Work in the project's own conventions
18
+
19
+ Inspect before you generate. This skill never introduces a project layout, a build tool or a test
20
+ runner the repository does not already use.
21
+
22
+ 1. How are existing Lambdas written and bundled here? Match it. If the project has its own function
23
+ construct, use that rather than `NodejsFunction`. A plugin that ships as an installable package is
24
+ the exception: it prebundles its handler and registers it with `Code.fromAsset`, so the deployment
25
+ installing it runs no bundler of its own.
26
+ 2. What frontend tooling exists? A plugin frontend is an ordinary bundle — any framework or none. Use
27
+ what the project already builds with.
28
+ 3. How are tests written? Mirror the nearest existing suite.
29
+
30
+ ## The shape
31
+
32
+ 1. **Decide the permissions.** Two levels exist: `user` and `admin`. `admin` includes `user` only when
33
+ the plugin declares `user`. Give each a label an administrator will read in the grant editor.
34
+ 2. **Decide the accounts.** A plugin is bound to specific accounts, and one request authorizes exactly
35
+ one of them. A handler must never act on an account other than the one in its authorizer context —
36
+ refuse instead, as the example does.
37
+ 3. **Write the routes.** Each names a method, a path relative to the account root, the permission it
38
+ requires, and the handler that serves it. Paths take literal segments and single-segment `{params}`.
39
+ 4. **Write the handler.** Take the authorizer context from the event; never re-read a permission, a
40
+ user or an account from the request. Answer domain 4xx codes for business failures — never 401,
41
+ which the SDK treats as the authorizer rejecting the caller and retries once.
42
+ 5. **Write the frontend.** Connect to the portal, read the accounts the caller may use (which one
43
+ the page works in is its own state), call your own API through the provided helper. Do not implement a login, store a token, or put one in a URL. Use the component
44
+ classes from `@fntio/infra-client-plugin-ui` (`applyPluginUi(document)`) rather than styling from
45
+ scratch — a page built on them matches the portal, and one that is not will look foreign however
46
+ carefully it is themed.
47
+ 6. **Bound the blast radius twice.** Whatever your handler refuses in code, its IAM policy should also
48
+ refuse. The example scopes both to configured name prefixes.
49
+
50
+ ## Checks before you hand it over
51
+
52
+ - Type-check and test with the project's own commands.
53
+ - Build the frontend. Registration fails at synth if the entry file is missing.
54
+ - Confirm no secret or parameter value reaches a log line.
55
+ - Confirm a request naming a different account is refused rather than served.
56
+
57
+ ## What this feature does not do
58
+
59
+ There is no per-resource permission below the account, no automatic IAM for your handler, no generated
60
+ project, and no CLI. Long-running work returns `202` with a job id and is polled by your own routes;
61
+ the platform provides no job runner and no websockets.