Skip to content

Commit a4b3c7d

Browse files
author
Konstantinos Bairaktaris
committed
Rudimentary code-completion in transifex/api
How to test: 1. Checkout this branch 2. `cd <path-to-repo>/packages/api` 3. `npm run build` 4. `npm link` 5. `cd <path-to-empty-folder` 6. `npm link @transifex/api` 7. Open `index.js` in vscode and type: ```javascript const { transifexApi } = require('@transifex/api'); transifexApi.setup({ auth: 'XXX' }); async function main() { const page = transifexApi.Organization.list(); await page.fetch(); console.log(page.data); } main(); ``` While observing what auto-completions the editor offers. After `transifexApi.` the editor should offer all API resource types registered with the SDK.
1 parent 636318d commit a4b3c7d

2 files changed

Lines changed: 64 additions & 1 deletion

File tree

packages/api/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@
4545
},
4646
"publishConfig": {
4747
"access": "public"
48-
}
48+
},
49+
"types": "src/transifexApi.d.ts"
4950
}

packages/api/src/transifexApi.d.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
3+
declare class JsonApiResource {
4+
}
5+
6+
declare export class TransifexApi {
7+
Organization: typeof JsonApiResource;
8+
User: typeof JsonApiResource;
9+
Language: typeof JsonApiResource;
10+
Project: typeof JsonApiResource;
11+
ProjectWebhook: typeof JsonApiResource;
12+
Resource: typeof JsonApiResource;
13+
ResourceString: typeof JsonApiResource;
14+
ResourceStringsAsyncDownload: typeof JsonApiResource;
15+
ResourceStringsAsyncUpload: typeof JsonApiResource;
16+
ResourceStringComment: typeof JsonApiResource;
17+
I18nFormat: typeof JsonApiResource;
18+
ContextScreenshotMap: typeof JsonApiResource;
19+
ContextScreenshot: typeof JsonApiResource;
20+
OrganizationActivityReportsAsyncDownload: typeof JsonApiResource;
21+
ProjectActivityReportsAsyncDownload: typeof JsonApiResource;
22+
ResourceActivityReportsAsyncDownload: typeof JsonApiResource;
23+
TeamActivityReportsAsyncDownload: typeof JsonApiResource;
24+
ResourceLanguageStats: typeof JsonApiResource;
25+
ResourceTranslation: typeof JsonApiResource;
26+
ResourceTranslationsAsyncDownload: typeof JsonApiResource;
27+
ResourceTranslationsAsyncUpload: typeof JsonApiResource;
28+
TeamMembership: typeof JsonApiResource;
29+
Team: typeof JsonApiResource;
30+
TmxAsyncDownload: typeof JsonApiResource;
31+
TmxAsyncUpload: typeof JsonApiResource;
32+
ResourceStringsRevision: typeof JsonApiResource;
33+
34+
organizations: typeof JsonApiResource;
35+
users: typeof JsonApiResource;
36+
languages: typeof JsonApiResource;
37+
projects: typeof JsonApiResource;
38+
project_webhooks: typeof JsonApiResource;
39+
resources: typeof JsonApiResource;
40+
resource_strings: typeof JsonApiResource;
41+
resource_strings_async_downloads: typeof JsonApiResource;
42+
resource_strings_async_uploads: typeof JsonApiResource;
43+
resource_string_comments: typeof JsonApiResource;
44+
i18n_formats: typeof JsonApiResource;
45+
context_screenshot_maps: typeof JsonApiResource;
46+
context_screenshots: typeof JsonApiResource;
47+
organization_activity_reports_async_downloads: typeof JsonApiResource;
48+
project_activity_reports_async_downloads: typeof JsonApiResource;
49+
resource_activity_reports_async_downloads: typeof JsonApiResource;
50+
team_activity_reports_async_downloads: typeof JsonApiResource;
51+
resource_language_stats: typeof JsonApiResource;
52+
resource_translations: typeof JsonApiResource;
53+
resource_translations_async_downloads: typeof JsonApiResource;
54+
resource_translations_async_uploads: typeof JsonApiResource;
55+
team_memberships: typeof JsonApiResource;
56+
teams: typeof JsonApiResource;
57+
tmx_async_downloads: typeof JsonApiResource;
58+
tmx_async_uploads: typeof JsonApiResource;
59+
resource_strings_revisions: typeof JsonApiResource;
60+
}
61+
62+
declare export var transifexApi: TransifexApi;

0 commit comments

Comments
 (0)