Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#71166 Added types for salling-group__auth by
Browse files Browse the repository at this point in the history
@HaayanchandravatSr

Co-authored-by: Arjuna Enait <[email protected]>
  • Loading branch information
HaayanchandravatSr and AlienistSolution authored Nov 22, 2024
1 parent ae0319b commit ca297b2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
5 changes: 5 additions & 0 deletions types/salling-group__auth/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
41 changes: 41 additions & 0 deletions types/salling-group__auth/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { AxiosInstance } from "axios";

export interface AuthOptions {
/** The type of authentication. */
type: "jwt" | "bearer";

/** The issuer used for JWT. */
issuer?: string;

/** The secret used for JWT. */
secret?: string;

/** The token used for Bearer. */
token?: string;
}

export interface InstanceOptions {
/** Credentials for the instance */
auth: AuthOptions;

/**
* The name of the application which will use this instance.
* This will be sent in the user-agent header.
*/
applicationName?: string;

/** The base name. (For internal use.) */
baseName?: string;
}

/**
* Create a new Axios instance with Salling Group API support.
* This automatically injects authorization and sets the base URL.
* Furthermore, it also wraps API errors into a designated error type.
* The instance can be used directly on resources (e.g. 'instance.get('/v1/stores/')').
*
* @param options Options for the instance
*
* @returns An Axios instance that can access the Salling Group API.
*/
export function createInstance(options: InstanceOptions): AxiosInstance;
20 changes: 20 additions & 0 deletions types/salling-group__auth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"name": "@types/salling-group__auth",
"version": "1.0.9999",
"projects": [
"https://github.com/DanskSupermarked/sg-npm-auth"
],
"owners": [
{
"name": "Arjuna Enait",
"githubUsername": "HaayanchandravatSr"
}
],
"dependencies": {
"axios": "^1.7.7"
},
"devDependencies": {
"@types/salling-group__auth": "workspace:."
}
}
12 changes: 12 additions & 0 deletions types/salling-group__auth/salling-group__auth.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createInstance } from "salling-group__auth";

createInstance({
auth: {
type: "jwt",
issuer: "issuer",
secret: "secret",
token: "token",
},
applicationName: "app",
baseName: "base",
});
19 changes: 19 additions & 0 deletions types/salling-group__auth/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"salling-group__auth.tests.ts"
]
}

0 comments on commit ca297b2

Please sign in to comment.