@lunch-money/v2-api-spec 2.11.1-preview.1 → 2.11.1-preview.11
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.
- package/README.md +21 -66
- package/lunch-money-api-v2.yaml +760 -405
- package/oauth-client-logo/index.d.ts +27 -0
- package/oauth-client-logo/index.js +32 -0
- package/oauth-scopes/catalog.d.ts +9 -0
- package/oauth-scopes/catalog.js +500 -0
- package/oauth-scopes/index.d.ts +2 -0
- package/oauth-scopes/index.js +12 -0
- package/oauth-scopes/types.d.ts +50 -0
- package/oauth-scopes/types.js +2 -0
- package/package.json +34 -9
- package/version-history.md +25 -19
- package/update-urls.sh +0 -135
package/README.md
CHANGED
|
@@ -14,6 +14,7 @@ After installation, the package provides:
|
|
|
14
14
|
|
|
15
15
|
- **OpenAPI Specification**: `node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yaml`
|
|
16
16
|
- **Version History**: `node_modules/@lunch-money/v2-api-spec/version-history.md`
|
|
17
|
+
- **OAuth scope catalog**: `@lunch-money/v2-api-spec/oauth-scopes`
|
|
17
18
|
|
|
18
19
|
## Usage
|
|
19
20
|
|
|
@@ -26,6 +27,22 @@ const specPath = require.resolve('@lunch-money/v2-api-spec/lunch-money-api-v2.ya
|
|
|
26
27
|
const spec = fs.readFileSync(specPath, 'utf8');
|
|
27
28
|
```
|
|
28
29
|
|
|
30
|
+
### Using the OAuth scope catalog
|
|
31
|
+
|
|
32
|
+
The package also provides immutable OAuth scope and scope-group definitions.
|
|
33
|
+
API scopes identify the V2 operations they authorize by `operationId`.
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
const {
|
|
37
|
+
getOAuthScopeDefinition,
|
|
38
|
+
matchOAuthScopeGroup,
|
|
39
|
+
oauthScopeGroups,
|
|
40
|
+
oauthScopes,
|
|
41
|
+
} = require('@lunch-money/v2-api-spec/oauth-scopes');
|
|
42
|
+
|
|
43
|
+
const transactionRead = getOAuthScopeDefinition('transactions:read');
|
|
44
|
+
```
|
|
45
|
+
|
|
29
46
|
### Using with OpenAPI Tools
|
|
30
47
|
|
|
31
48
|
```bash
|
|
@@ -39,73 +56,11 @@ npx @openapitools/openapi-generator-cli generate \
|
|
|
39
56
|
npx swagger-cli validate node_modules/@lunch-money/v2-api-spec/lunch-money-api-v2.yaml
|
|
40
57
|
```
|
|
41
58
|
|
|
42
|
-
###
|
|
43
|
-
|
|
44
|
-
The package includes a script to help switch between local and production URLs in the OpenAPI specification. This is useful when developing against a local server.
|
|
45
|
-
|
|
46
|
-
#### Using the Script
|
|
47
|
-
|
|
48
|
-
The script is located at `node_modules/@lunch-money/v2-api-spec/update-urls.sh`.
|
|
49
|
-
|
|
50
|
-
**Required flags:**
|
|
51
|
-
- `--local` - Switch URLs to local development (default: `http://localhost:3000/v2`)
|
|
52
|
-
- `--production` - Switch URLs to production deployment URLs
|
|
53
|
-
|
|
54
|
-
**Switch to production URLs (using defaults):**
|
|
55
|
-
```bash
|
|
56
|
-
cd node_modules/@lunch-money/v2-api-spec
|
|
57
|
-
./update-urls.sh --production
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**Switch to production URLs (with custom URLs):**
|
|
61
|
-
```bash
|
|
62
|
-
cd node_modules/@lunch-money/v2-api-spec
|
|
63
|
-
API_DEPLOY_URL=https://api.lunchmoney.app/v2 \
|
|
64
|
-
DOCS_DEPLOY_URL=https://alpha.lunchmoney.app/v2 \
|
|
65
|
-
./update-urls.sh --production
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Switch to local URLs:**
|
|
69
|
-
```bash
|
|
70
|
-
cd node_modules/@lunch-money/v2-api-spec
|
|
71
|
-
./update-urls.sh --local
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Switch to local URLs (with custom local URL):**
|
|
75
|
-
```bash
|
|
76
|
-
cd node_modules/@lunch-money/v2-api-spec
|
|
77
|
-
LOCAL_URL=http://localhost:4000/v2 ./update-urls.sh --local
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**Using environment variables:**
|
|
81
|
-
Create a `.env` file in the package directory:
|
|
82
|
-
```bash
|
|
83
|
-
LOCAL_URL=http://localhost:3000/v2
|
|
84
|
-
API_DEPLOY_URL=https://api.lunchmoney.app/v2
|
|
85
|
-
DOCS_DEPLOY_URL=https://alpha.lunchmoney.app/v2
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Then run:
|
|
89
|
-
```bash
|
|
90
|
-
./update-urls.sh --production
|
|
91
|
-
# or
|
|
92
|
-
./update-urls.sh --local
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
#### How It Works
|
|
96
|
-
|
|
97
|
-
The script updates the `servers` section in the OpenAPI specification:
|
|
98
|
-
- **Server 1**: Typically the production API server
|
|
99
|
-
- **Server 2**: Typically a mock or staging server
|
|
100
|
-
|
|
101
|
-
It also updates any references to these URLs throughout the specification file.
|
|
102
|
-
|
|
103
|
-
#### Important Notes
|
|
59
|
+
### Spec URLs
|
|
104
60
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- The script works in both the npm package and the git repository
|
|
61
|
+
The published YAML uses public production docs/API URLs. Do not rewrite them in this
|
|
62
|
+
package for local or deploy environments — consuming apps (for example the Lunch Money
|
|
63
|
+
docs/mock server) should rewrite an installed copy when needed.
|
|
109
64
|
|
|
110
65
|
## Versioning
|
|
111
66
|
|