@zthun/helpful-internet 0.21.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.
- package/LICENSE +16 -0
- package/dist/lib/index.esm.js +2 -0
- package/dist/lib/index.esm.js.map +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/types/cookie/cookie.d.ts +171 -0
- package/dist/types/email/email-contact-address.d.ts +49 -0
- package/dist/types/email/email-contact.d.ts +91 -0
- package/dist/types/email/email-envelope.d.ts +135 -0
- package/dist/types/email/email.d.ts +87 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/server/server.d.ts +107 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2023 Anthony Bonta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
11
|
+
Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function t(){return t=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},t.apply(this,arguments)}var i=/*#__PURE__*/function(){function i(){this._cookie=void 0,this.immortal=this.expires.bind(this,void 0),this.lax=this.sameSite.bind(this,"lax"),this.strict=this.sameSite.bind(this,"strict"),this._cookie={name:"",value:""}}var e=i.prototype;return e.name=function(t){return this._cookie.name=t,this},e.value=function(t){return this._cookie.value=t,this},e.domain=function(t){return this._cookie.domain=t,this},e.expires=function(t){return null==t?(delete this._cookie.expires,this):(this._cookie.expires="string"==typeof t?t:t.toJSON(),this)},e.expiresTomorrow=function(){return this.expires(new Date(Date.now()+i.MillisecondsOneDay))},e.secure=function(t){return void 0===t&&(t=!0),this._cookie.secure=t,this},e.sameSite=function(t){return this._cookie.sameSite=t,this},e.allowCrossSite=function(){return this.secure().sameSite("none")},e.httpOnly=function(t){return void 0===t&&(t=!0),this._cookie.httpOnly=t,this},e.authentication=function(t){var i=this.name("Authentication").expiresTomorrow().secure().httpOnly();return null==t?i:i.value(t)},e.build=function(){return t({},this._cookie)},i}();i.MillisecondsOneDay=864e5;var e=/*#__PURE__*/function(){function t(){this._envelope=void 0,this._envelope={from:""}}var i=t.prototype;return i.from=function(t){return this._envelope.from=t,this},i.to=function(t){return this._envelope.to=this._envelope.to||[],this._envelope.to.push(t),this},i.tos=function(t){return this._envelope.to=t,this},i.cc=function(t){return this._envelope.cc=this._envelope.cc||[],this._envelope.cc.push(t),this},i.ccs=function(t){return this._envelope.cc=t,this},i.bcc=function(t){return this._envelope.bcc=this._envelope.bcc||[],this._envelope.bcc.push(t),this},i.bccs=function(t){return this._envelope.bcc=t,this},i.assign=function(t){return this._envelope=Object.assign({},this._envelope,t),this._envelope=JSON.parse(JSON.stringify(this._envelope)),this},i.copy=function(t){return this._envelope=JSON.parse(JSON.stringify(t)),this},i.build=function(){return JSON.parse(JSON.stringify(this._envelope))},t}(),n=/*#__PURE__*/function(){function t(){this._email=void 0,this._email={envelope:(new e).build()}}var i=t.prototype;return i.envelope=function(t){return this._email.envelope=t,this},i.subject=function(t){return this._email.subject=t,this},i.message=function(t){return this._email.message=t,this},i.assign=function(t){return this._email=Object.assign(this._email,t),this._email=JSON.parse(JSON.stringify(this._email)),this},i.copy=function(t){return this._email=JSON.parse(JSON.stringify(t)),this},i.build=function(){return JSON.parse(JSON.stringify(this._email))},t}(),s=/*#__PURE__*/function(){function t(){this._contact=void 0,this._contact={address:""}}var i=t.prototype;return i.address=function(t){return this._contact.address=t,this},i.type=function(t){return this._contact.type=t,this},i.display=function(t){return this._contact.display=t,this},i.assign=function(t){return this._contact=Object.assign({},this._contact,t),this._contact=JSON.parse(JSON.stringify(this._contact)),this},i.copy=function(t){return this._contact=JSON.parse(JSON.stringify(t)),this},i.build=function(){return JSON.parse(JSON.stringify(this._contact))},t}(),r=/*#__PURE__*/function(){function t(){this._addresses=[],this._delimiter=", "}var i=t.prototype;return i.address=function(t){return this._addresses.push(t),this},i.addresses=function(t){return this._addresses=t.slice(),this},i.delimiter=function(t){return this._delimiter=t,this},i.build=function(){return this._addresses.map(function(t){if(t)return"string"==typeof t?t:t.address}).filter(function(t){return!!t}).join(this._delimiter)},t}(),o=/*#__PURE__*/function(){function t(){this._server=void 0,this._server={address:""}}var i=t.prototype;return i.address=function(t){return this._server.address=t,this},i.port=function(t){return this._server.port=t,this},i.username=function(t){return this._server.username=t,this},i.password=function(t){return this._server.password=t,this},i.assign=function(t){return this._server=Object.assign({},this._server,t),this},i.copy=function(t){return this._server=JSON.parse(JSON.stringify(t)),this},i.build=function(){return JSON.parse(JSON.stringify(this._server))},t}();export{i as ZCookieBuilder,n as ZEmailBuilder,r as ZEmailContactAddressBuilder,s as ZEmailContactBuilder,e as ZEmailEnvelopeBuilder,o as ZServerBuilder};
|
|
2
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/cookie/cookie.ts","../../src/email/email-envelope.ts","../../src/email/email.ts","../../src/email/email-contact.ts","../../src/email/email-contact-address.ts","../../src/server/server.ts"],"sourcesContent":["/**\n * Represents a generic cookie.\n */\nexport interface IZCookie {\n /**\n * The cookie name.\n */\n name: string;\n /**\n * The cookie value.\n */\n value: string;\n /**\n * The scope domain attached to the cookie.\n */\n domain?: string;\n /**\n * The utc formatted date at which the cookie expires\n */\n expires?: string;\n /**\n * A flag that determines if this is a secure cookie.\n */\n secure?: boolean;\n /**\n * A flag that determines if this cookie can be ready by javascript.\n */\n httpOnly?: boolean;\n /**\n * A value that determines how the cookie is sent by the browser.\n */\n sameSite?: 'lax' | 'strict' | 'none';\n}\n\n/**\n * Represents a builder for an IZCookie object.\n */\nexport class ZCookieBuilder {\n public static readonly MillisecondsOneDay = 86400000;\n\n private _cookie: IZCookie;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._cookie = {\n name: '',\n value: ''\n };\n }\n\n /**\n * Sets the cookie name.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public name(val: string): this {\n this._cookie.name = val;\n return this;\n }\n\n /**\n * Sets the cookie value.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public value(val: string): this {\n this._cookie.value = val;\n return this;\n }\n\n /**\n * Sets the cookie domain.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public domain(val: string | undefined): this {\n this._cookie.domain = val;\n return this;\n }\n\n /**\n * Sets the cookie expiration date.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public expires(val: Date | string | undefined): this {\n if (val == null) {\n delete this._cookie.expires;\n return this;\n }\n\n this._cookie.expires = typeof val === 'string' ? val : val.toJSON();\n return this;\n }\n\n /**\n * Sets the cookie expiration date to one day from the moment this is invoked.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public expiresTomorrow(): this {\n return this.expires(new Date(Date.now() + ZCookieBuilder.MillisecondsOneDay));\n }\n\n /**\n * Removes the cookie expiration.\n *\n * @returns\n * This object.\n */\n public immortal: () => this = this.expires.bind(this, undefined);\n\n /**\n * Sets the cookie secure flag.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public secure(val = true): this {\n this._cookie.secure = val;\n return this;\n }\n\n /**\n * Sets the cookie same site policy.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public sameSite(val: 'lax' | 'strict' | 'none'): this {\n this._cookie.sameSite = val;\n return this;\n }\n\n /**\n * Sets the same site policy to 'lax'\n *\n * @returns\n * This object.\n */\n public lax = this.sameSite.bind(this, 'lax');\n\n /**\n * Sets the same site polity to 'strict'\n *\n * @returns\n * This object.\n */\n public strict = this.sameSite.bind(this, 'strict');\n\n /**\n * Sets the same site policy to 'none' and turns on the secure flag.\n *\n * @returns\n * This object.\n */\n public allowCrossSite(): this {\n return this.secure().sameSite('none');\n }\n\n /**\n * Sets the cookie http only flag.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public httpOnly(val = true): this {\n this._cookie.httpOnly = val;\n return this;\n }\n\n /**\n * Creates a token based authentication cookie.\n *\n * @param token -\n * The token value for the cookie. You\n * can leave this as undefined to set it\n * later.\n *\n * @returns\n * This object.\n */\n public authentication(token?: string): this {\n const builder = this.name('Authentication').expiresTomorrow().secure().httpOnly();\n return token == null ? builder : builder.value(token);\n }\n\n /**\n * Returns a copy of the built instance of the cookie.\n *\n * @returns\n * A shallow copy of the current cookie object.\n */\n public build(): IZCookie {\n return { ...this._cookie };\n }\n}\n","import { IZEmailContact } from './email-contact';\n\n/**\n * Represents an email envelope of information about who the email is from and where it's going to.\n */\nexport interface IZEmailEnvelope {\n /**\n * Who the email is from.\n *\n * This can be the full contact or just the address.\n */\n from: IZEmailContact | string;\n\n /**\n * Where the email is going.\n *\n * This can be falsy if cc is filled out.\n */\n to?: Array<IZEmailContact | string>;\n\n /**\n * Who is receiving a carbon copy of the email.\n *\n * This can be falsy if to is filled out.\n */\n cc?: Array<IZEmailContact | string>;\n\n /**\n * Who is receiving a blind carbon copy of an email.\n */\n bcc?: Array<IZEmailContact | string>;\n}\n\n/**\n * Represents a builder for an email envelope.\n */\nexport class ZEmailEnvelopeBuilder {\n private _envelope: IZEmailEnvelope;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._envelope = {\n from: ''\n };\n }\n\n /**\n * Sets the from field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public from(val: IZEmailContact | string): this {\n this._envelope.from = val;\n return this;\n }\n\n /**\n * Adds a value to the 'to' field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public to(val: IZEmailContact | string): this {\n this._envelope.to = this._envelope.to || [];\n this._envelope.to.push(val);\n return this;\n }\n\n /**\n * Sets the to field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public tos(val: Array<IZEmailContact | string>): this {\n this._envelope.to = val;\n return this;\n }\n\n /**\n * Adds a value to the cc field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public cc(val: IZEmailContact | string): this {\n this._envelope.cc = this._envelope.cc || [];\n this._envelope.cc.push(val);\n return this;\n }\n\n /**\n * Sets the cc field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public ccs(val: Array<IZEmailContact | string>): this {\n this._envelope.cc = val;\n return this;\n }\n\n /**\n * Adds a value to the bcc field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public bcc(val: IZEmailContact | string): this {\n this._envelope.bcc = this._envelope.bcc || [];\n this._envelope.bcc.push(val);\n return this;\n }\n\n /**\n * Sets the bcc field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bccs(val: Array<IZEmailContact | string>): this {\n this._envelope.bcc = val;\n return this;\n }\n\n /**\n * Assigns another partial email envelope to this object.\n *\n * @param other -\n * The value to partial copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmailEnvelope>): this {\n this._envelope = Object.assign({}, this._envelope, other);\n this._envelope = JSON.parse(JSON.stringify(this._envelope));\n return this;\n }\n\n /**\n * Copies another email envelope to this object.\n *\n * @param other -\n * The value to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmailEnvelope): this {\n this._envelope = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built envelope.\n *\n * @returns\n * A copy of the currently built up envelope object.\n */\n public build(): IZEmailEnvelope {\n return JSON.parse(JSON.stringify(this._envelope));\n }\n}\n","import { IZEmailEnvelope, ZEmailEnvelopeBuilder } from './email-envelope';\n\n/**\n * Represents an email message.\n */\nexport interface IZEmail {\n /**\n * The email envelope of where the email is going to.\n */\n envelope: IZEmailEnvelope;\n\n /**\n * The subject (title) of the email.\n */\n subject?: string;\n\n /**\n * The message to send.\n */\n message?: string;\n}\n\n/**\n * Represents a builder for an email.\n */\nexport class ZEmailBuilder {\n private _email: IZEmail;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._email = {\n envelope: new ZEmailEnvelopeBuilder().build()\n };\n }\n\n /**\n * Sets the envelope of where the email is going.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public envelope(val: IZEmailEnvelope): this {\n this._email.envelope = val;\n return this;\n }\n\n /**\n * Sets the subject line of the email.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public subject(val: string): this {\n this._email.subject = val;\n return this;\n }\n\n /**\n * Sets the message of the email.\n *\n * The message can be raw text or html.\n *\n * @param val -\n * A html enabled formatted message to set.\n *\n * @returns\n * This object.\n */\n public message(val: string): this {\n this._email.message = val;\n return this;\n }\n\n /**\n * Assigns the other object to the current email object.\n *\n * @param other -\n * The object to copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmail>): this {\n this._email = Object.assign(this._email, other);\n this._email = JSON.parse(JSON.stringify(this._email));\n return this;\n }\n\n /**\n * Copies another email into the builder.\n *\n * @param other -\n * The object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmail) {\n this._email = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built object.\n */\n public build(): IZEmail {\n return JSON.parse(JSON.stringify(this._email));\n }\n}\n","/**\n * Represents an email contact.\n */\nexport interface IZEmailContact {\n /**\n * The email address of the contact.\n */\n address: string;\n\n /**\n * The type of contact.\n *\n * This can be anything you want. In the end, this has no bearing\n * on the final sent message. It's just a descriptor to determine what this contact\n * represents if needed.\n */\n type?: string;\n\n /**\n * The display name of the contact.\n *\n * If this is falsy, then you can consider the\n * address as the display.\n */\n display?: string;\n}\n\n/**\n * Represents a builder for an email contact.\n */\nexport class ZEmailContactBuilder {\n private _contact: IZEmailContact;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._contact = {\n address: ''\n };\n }\n\n /**\n * Sets the address of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public address(val: string): this {\n this._contact.address = val;\n return this;\n }\n\n /**\n * Sets the type of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public type(val: string): this {\n this._contact.type = val;\n return this;\n }\n\n /**\n * Sets the display of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public display(val: string) {\n this._contact.display = val;\n return this;\n }\n\n /**\n * Assigns the values in other to this object.\n *\n * @param other -\n * The value to partial copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmailContact>): this {\n this._contact = Object.assign({}, this._contact, other);\n this._contact = JSON.parse(JSON.stringify(this._contact));\n return this;\n }\n\n /**\n * Copies another object.\n *\n * @param other -\n * The value to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmailContact): this {\n this._contact = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built email contact.\n */\n public build(): IZEmailContact {\n return JSON.parse(JSON.stringify(this._contact));\n }\n}\n","import { IZEmailContact } from './email-contact';\n\n/**\n * Represents a builder that will build a comma separated\n * list of addresses for an email message.\n */\nexport class ZEmailContactAddressBuilder {\n private _addresses: Array<string | IZEmailContact> = [];\n private _delimiter = ', ';\n\n /**\n * Adds an address to the list to builder.\n *\n * @param val -\n * The address to add. This can be the empty string,\n * null, or undefined.\n *\n * @returns\n * This object.\n */\n public address(val: string | IZEmailContact): this {\n this._addresses.push(val);\n return this;\n }\n\n /**\n * Sets the addresses to build from.\n *\n * @param val -\n * The address to set.\n *\n * @returns\n * This object.\n */\n public addresses(val: Array<string | IZEmailContact>) {\n this._addresses = val.slice();\n return this;\n }\n\n /**\n * Sets the delimiter to split the addresses with.\n *\n * The default is a comma with a space.\n *\n * @param val -\n * The delimiter to set.\n *\n * @returns\n * This object.\n */\n public delimiter(val: string): this {\n this._delimiter = val;\n return this;\n }\n\n /**\n * Builds the delimiters separated list of addresses.\n *\n * @returns\n * The delimited separated list of addresses.\n */\n public build(): string {\n const addr = (ct: string | IZEmailContact) => {\n if (!ct) {\n return undefined;\n }\n\n return typeof ct === 'string' ? ct : ct.address;\n };\n\n const truthy = (ct: string) => {\n return !!ct;\n };\n\n return this._addresses.map(addr).filter(truthy).join(this._delimiter);\n }\n}\n","/**\n * Represents an abstract server connection.\n */\nexport interface IZServer {\n /**\n * The host or ip address to connect to.\n *\n * Does not distinguish between the protocol and hostname.\n */\n address: string;\n\n /**\n * The optional port to connect on.\n *\n * If this is falsy, then it is up to the implementation\n * taking this object to properly default the value.\n */\n port?: number;\n\n /**\n * The optional username.\n *\n * Falsy usually implies guest access.\n */\n username?: string;\n\n /**\n * The user's password to connect with.\n *\n * If username is not supplied, then this generally has no meaning.\n */\n password?: string;\n}\n\n/**\n * Represents a builder for a server object.\n */\nexport class ZServerBuilder {\n private _server: IZServer;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._server = {\n address: ''\n };\n }\n\n /**\n * The server ip address or hostname.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public address(val: string): this {\n this._server.address = val;\n return this;\n }\n\n /**\n * Sets the optional port to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public port(val: number): this {\n this._server.port = val;\n return this;\n }\n\n /**\n * Sets the optional username to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public username(val: string): this {\n this._server.username = val;\n return this;\n }\n\n /**\n * Sets the password to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public password(val: string): this {\n this._server.password = val;\n return this;\n }\n\n /**\n * Assigns all truthy properties in other to this object.\n *\n * @param other -\n * The server object to copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZServer>): this {\n this._server = Object.assign({}, this._server, other);\n return this;\n }\n\n /**\n * Copies all properties in other to this object.\n *\n * @param other -\n * The server object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZServer): this {\n this._server = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built object.\n */\n public build(): IZServer {\n return JSON.parse(JSON.stringify(this._server));\n }\n}\n"],"names":["ZCookieBuilder","_cookie","this","immortal","expires","bind","undefined","lax","sameSite","strict","name","value","_proto","prototype","val","domain","toJSON","expiresTomorrow","Date","now","MillisecondsOneDay","secure","allowCrossSite","httpOnly","authentication","token","builder","build","_extends","ZEmailEnvelopeBuilder","_envelope","from","to","push","tos","cc","ccs","bcc","bccs","assign","other","Object","JSON","parse","stringify","copy","ZEmailBuilder","_email","envelope","subject","message","ZEmailContactBuilder","_contact","address","type","display","ZEmailContactAddressBuilder","_addresses","_delimiter","addresses","slice","delimiter","map","ct","filter","join","ZServerBuilder","_server","port","username","password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AWM0D,SAAA,SAASxD,GAEd,OADAZ,KAAKiE,QAAQG,SAAWxD,EAE1BZ,IAAA,EAACU,EAWM2B,OAAA,SAAOC,GAEZ,OADAtC,KAAKiE,QAAU1B,OAAOF,OAAO,CAAE,EAAErC,KAAKiE,QAAS3B,GAEjDtC,IAAA,EAACU,EAWMiC,KAAA,SAAKL,GAEV,OADAtC,KAAKiE,QAAUzB,KAAKC,MAAMD,KAAKE,UAAUJ,IAClCtC,IACT,EAACU,EAQMe,MAAA,WACL,OAAOe,KAAKC,MAAMD,KAAKE,UAAU1C,KAAKiE,SACxC,EAACD,CAAA,CAlGD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},t.apply(this,arguments)}var e=/*#__PURE__*/function(){function e(){this._cookie=void 0,this.immortal=this.expires.bind(this,void 0),this.lax=this.sameSite.bind(this,"lax"),this.strict=this.sameSite.bind(this,"strict"),this._cookie={name:"",value:""}}var i=e.prototype;return i.name=function(t){return this._cookie.name=t,this},i.value=function(t){return this._cookie.value=t,this},i.domain=function(t){return this._cookie.domain=t,this},i.expires=function(t){return null==t?(delete this._cookie.expires,this):(this._cookie.expires="string"==typeof t?t:t.toJSON(),this)},i.expiresTomorrow=function(){return this.expires(new Date(Date.now()+e.MillisecondsOneDay))},i.secure=function(t){return void 0===t&&(t=!0),this._cookie.secure=t,this},i.sameSite=function(t){return this._cookie.sameSite=t,this},i.allowCrossSite=function(){return this.secure().sameSite("none")},i.httpOnly=function(t){return void 0===t&&(t=!0),this._cookie.httpOnly=t,this},i.authentication=function(t){var e=this.name("Authentication").expiresTomorrow().secure().httpOnly();return null==t?e:e.value(t)},i.build=function(){return t({},this._cookie)},e}();e.MillisecondsOneDay=864e5;var i=/*#__PURE__*/function(){function t(){this._envelope=void 0,this._envelope={from:""}}var e=t.prototype;return e.from=function(t){return this._envelope.from=t,this},e.to=function(t){return this._envelope.to=this._envelope.to||[],this._envelope.to.push(t),this},e.tos=function(t){return this._envelope.to=t,this},e.cc=function(t){return this._envelope.cc=this._envelope.cc||[],this._envelope.cc.push(t),this},e.ccs=function(t){return this._envelope.cc=t,this},e.bcc=function(t){return this._envelope.bcc=this._envelope.bcc||[],this._envelope.bcc.push(t),this},e.bccs=function(t){return this._envelope.bcc=t,this},e.assign=function(t){return this._envelope=Object.assign({},this._envelope,t),this._envelope=JSON.parse(JSON.stringify(this._envelope)),this},e.copy=function(t){return this._envelope=JSON.parse(JSON.stringify(t)),this},e.build=function(){return JSON.parse(JSON.stringify(this._envelope))},t}(),n=/*#__PURE__*/function(){function t(){this._email=void 0,this._email={envelope:(new i).build()}}var e=t.prototype;return e.envelope=function(t){return this._email.envelope=t,this},e.subject=function(t){return this._email.subject=t,this},e.message=function(t){return this._email.message=t,this},e.assign=function(t){return this._email=Object.assign(this._email,t),this._email=JSON.parse(JSON.stringify(this._email)),this},e.copy=function(t){return this._email=JSON.parse(JSON.stringify(t)),this},e.build=function(){return JSON.parse(JSON.stringify(this._email))},t}(),s=/*#__PURE__*/function(){function t(){this._contact=void 0,this._contact={address:""}}var e=t.prototype;return e.address=function(t){return this._contact.address=t,this},e.type=function(t){return this._contact.type=t,this},e.display=function(t){return this._contact.display=t,this},e.assign=function(t){return this._contact=Object.assign({},this._contact,t),this._contact=JSON.parse(JSON.stringify(this._contact)),this},e.copy=function(t){return this._contact=JSON.parse(JSON.stringify(t)),this},e.build=function(){return JSON.parse(JSON.stringify(this._contact))},t}(),r=/*#__PURE__*/function(){function t(){this._addresses=[],this._delimiter=", "}var e=t.prototype;return e.address=function(t){return this._addresses.push(t),this},e.addresses=function(t){return this._addresses=t.slice(),this},e.delimiter=function(t){return this._delimiter=t,this},e.build=function(){return this._addresses.map(function(t){if(t)return"string"==typeof t?t:t.address}).filter(function(t){return!!t}).join(this._delimiter)},t}(),o=/*#__PURE__*/function(){function t(){this._server=void 0,this._server={address:""}}var e=t.prototype;return e.address=function(t){return this._server.address=t,this},e.port=function(t){return this._server.port=t,this},e.username=function(t){return this._server.username=t,this},e.password=function(t){return this._server.password=t,this},e.assign=function(t){return this._server=Object.assign({},this._server,t),this},e.copy=function(t){return this._server=JSON.parse(JSON.stringify(t)),this},e.build=function(){return JSON.parse(JSON.stringify(this._server))},t}();exports.ZCookieBuilder=e,exports.ZEmailBuilder=n,exports.ZEmailContactAddressBuilder=r,exports.ZEmailContactBuilder=s,exports.ZEmailEnvelopeBuilder=i,exports.ZServerBuilder=o;
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/cookie/cookie.ts","../../src/email/email-envelope.ts","../../src/email/email.ts","../../src/email/email-contact.ts","../../src/email/email-contact-address.ts","../../src/server/server.ts"],"sourcesContent":["/**\n * Represents a generic cookie.\n */\nexport interface IZCookie {\n /**\n * The cookie name.\n */\n name: string;\n /**\n * The cookie value.\n */\n value: string;\n /**\n * The scope domain attached to the cookie.\n */\n domain?: string;\n /**\n * The utc formatted date at which the cookie expires\n */\n expires?: string;\n /**\n * A flag that determines if this is a secure cookie.\n */\n secure?: boolean;\n /**\n * A flag that determines if this cookie can be ready by javascript.\n */\n httpOnly?: boolean;\n /**\n * A value that determines how the cookie is sent by the browser.\n */\n sameSite?: 'lax' | 'strict' | 'none';\n}\n\n/**\n * Represents a builder for an IZCookie object.\n */\nexport class ZCookieBuilder {\n public static readonly MillisecondsOneDay = 86400000;\n\n private _cookie: IZCookie;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._cookie = {\n name: '',\n value: ''\n };\n }\n\n /**\n * Sets the cookie name.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public name(val: string): this {\n this._cookie.name = val;\n return this;\n }\n\n /**\n * Sets the cookie value.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public value(val: string): this {\n this._cookie.value = val;\n return this;\n }\n\n /**\n * Sets the cookie domain.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public domain(val: string | undefined): this {\n this._cookie.domain = val;\n return this;\n }\n\n /**\n * Sets the cookie expiration date.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public expires(val: Date | string | undefined): this {\n if (val == null) {\n delete this._cookie.expires;\n return this;\n }\n\n this._cookie.expires = typeof val === 'string' ? val : val.toJSON();\n return this;\n }\n\n /**\n * Sets the cookie expiration date to one day from the moment this is invoked.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public expiresTomorrow(): this {\n return this.expires(new Date(Date.now() + ZCookieBuilder.MillisecondsOneDay));\n }\n\n /**\n * Removes the cookie expiration.\n *\n * @returns\n * This object.\n */\n public immortal: () => this = this.expires.bind(this, undefined);\n\n /**\n * Sets the cookie secure flag.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public secure(val = true): this {\n this._cookie.secure = val;\n return this;\n }\n\n /**\n * Sets the cookie same site policy.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public sameSite(val: 'lax' | 'strict' | 'none'): this {\n this._cookie.sameSite = val;\n return this;\n }\n\n /**\n * Sets the same site policy to 'lax'\n *\n * @returns\n * This object.\n */\n public lax = this.sameSite.bind(this, 'lax');\n\n /**\n * Sets the same site polity to 'strict'\n *\n * @returns\n * This object.\n */\n public strict = this.sameSite.bind(this, 'strict');\n\n /**\n * Sets the same site policy to 'none' and turns on the secure flag.\n *\n * @returns\n * This object.\n */\n public allowCrossSite(): this {\n return this.secure().sameSite('none');\n }\n\n /**\n * Sets the cookie http only flag.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public httpOnly(val = true): this {\n this._cookie.httpOnly = val;\n return this;\n }\n\n /**\n * Creates a token based authentication cookie.\n *\n * @param token -\n * The token value for the cookie. You\n * can leave this as undefined to set it\n * later.\n *\n * @returns\n * This object.\n */\n public authentication(token?: string): this {\n const builder = this.name('Authentication').expiresTomorrow().secure().httpOnly();\n return token == null ? builder : builder.value(token);\n }\n\n /**\n * Returns a copy of the built instance of the cookie.\n *\n * @returns\n * A shallow copy of the current cookie object.\n */\n public build(): IZCookie {\n return { ...this._cookie };\n }\n}\n","import { IZEmailContact } from './email-contact';\n\n/**\n * Represents an email envelope of information about who the email is from and where it's going to.\n */\nexport interface IZEmailEnvelope {\n /**\n * Who the email is from.\n *\n * This can be the full contact or just the address.\n */\n from: IZEmailContact | string;\n\n /**\n * Where the email is going.\n *\n * This can be falsy if cc is filled out.\n */\n to?: Array<IZEmailContact | string>;\n\n /**\n * Who is receiving a carbon copy of the email.\n *\n * This can be falsy if to is filled out.\n */\n cc?: Array<IZEmailContact | string>;\n\n /**\n * Who is receiving a blind carbon copy of an email.\n */\n bcc?: Array<IZEmailContact | string>;\n}\n\n/**\n * Represents a builder for an email envelope.\n */\nexport class ZEmailEnvelopeBuilder {\n private _envelope: IZEmailEnvelope;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._envelope = {\n from: ''\n };\n }\n\n /**\n * Sets the from field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public from(val: IZEmailContact | string): this {\n this._envelope.from = val;\n return this;\n }\n\n /**\n * Adds a value to the 'to' field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public to(val: IZEmailContact | string): this {\n this._envelope.to = this._envelope.to || [];\n this._envelope.to.push(val);\n return this;\n }\n\n /**\n * Sets the to field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public tos(val: Array<IZEmailContact | string>): this {\n this._envelope.to = val;\n return this;\n }\n\n /**\n * Adds a value to the cc field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public cc(val: IZEmailContact | string): this {\n this._envelope.cc = this._envelope.cc || [];\n this._envelope.cc.push(val);\n return this;\n }\n\n /**\n * Sets the cc field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public ccs(val: Array<IZEmailContact | string>): this {\n this._envelope.cc = val;\n return this;\n }\n\n /**\n * Adds a value to the bcc field.\n *\n * @param val -\n * The value to add.\n *\n * @returns\n * This object.\n */\n public bcc(val: IZEmailContact | string): this {\n this._envelope.bcc = this._envelope.bcc || [];\n this._envelope.bcc.push(val);\n return this;\n }\n\n /**\n * Sets the bcc field.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bccs(val: Array<IZEmailContact | string>): this {\n this._envelope.bcc = val;\n return this;\n }\n\n /**\n * Assigns another partial email envelope to this object.\n *\n * @param other -\n * The value to partial copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmailEnvelope>): this {\n this._envelope = Object.assign({}, this._envelope, other);\n this._envelope = JSON.parse(JSON.stringify(this._envelope));\n return this;\n }\n\n /**\n * Copies another email envelope to this object.\n *\n * @param other -\n * The value to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmailEnvelope): this {\n this._envelope = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built envelope.\n *\n * @returns\n * A copy of the currently built up envelope object.\n */\n public build(): IZEmailEnvelope {\n return JSON.parse(JSON.stringify(this._envelope));\n }\n}\n","import { IZEmailEnvelope, ZEmailEnvelopeBuilder } from './email-envelope';\n\n/**\n * Represents an email message.\n */\nexport interface IZEmail {\n /**\n * The email envelope of where the email is going to.\n */\n envelope: IZEmailEnvelope;\n\n /**\n * The subject (title) of the email.\n */\n subject?: string;\n\n /**\n * The message to send.\n */\n message?: string;\n}\n\n/**\n * Represents a builder for an email.\n */\nexport class ZEmailBuilder {\n private _email: IZEmail;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._email = {\n envelope: new ZEmailEnvelopeBuilder().build()\n };\n }\n\n /**\n * Sets the envelope of where the email is going.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public envelope(val: IZEmailEnvelope): this {\n this._email.envelope = val;\n return this;\n }\n\n /**\n * Sets the subject line of the email.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public subject(val: string): this {\n this._email.subject = val;\n return this;\n }\n\n /**\n * Sets the message of the email.\n *\n * The message can be raw text or html.\n *\n * @param val -\n * A html enabled formatted message to set.\n *\n * @returns\n * This object.\n */\n public message(val: string): this {\n this._email.message = val;\n return this;\n }\n\n /**\n * Assigns the other object to the current email object.\n *\n * @param other -\n * The object to copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmail>): this {\n this._email = Object.assign(this._email, other);\n this._email = JSON.parse(JSON.stringify(this._email));\n return this;\n }\n\n /**\n * Copies another email into the builder.\n *\n * @param other -\n * The object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmail) {\n this._email = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built object.\n */\n public build(): IZEmail {\n return JSON.parse(JSON.stringify(this._email));\n }\n}\n","/**\n * Represents an email contact.\n */\nexport interface IZEmailContact {\n /**\n * The email address of the contact.\n */\n address: string;\n\n /**\n * The type of contact.\n *\n * This can be anything you want. In the end, this has no bearing\n * on the final sent message. It's just a descriptor to determine what this contact\n * represents if needed.\n */\n type?: string;\n\n /**\n * The display name of the contact.\n *\n * If this is falsy, then you can consider the\n * address as the display.\n */\n display?: string;\n}\n\n/**\n * Represents a builder for an email contact.\n */\nexport class ZEmailContactBuilder {\n private _contact: IZEmailContact;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._contact = {\n address: ''\n };\n }\n\n /**\n * Sets the address of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public address(val: string): this {\n this._contact.address = val;\n return this;\n }\n\n /**\n * Sets the type of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public type(val: string): this {\n this._contact.type = val;\n return this;\n }\n\n /**\n * Sets the display of the contact.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public display(val: string) {\n this._contact.display = val;\n return this;\n }\n\n /**\n * Assigns the values in other to this object.\n *\n * @param other -\n * The value to partial copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZEmailContact>): this {\n this._contact = Object.assign({}, this._contact, other);\n this._contact = JSON.parse(JSON.stringify(this._contact));\n return this;\n }\n\n /**\n * Copies another object.\n *\n * @param other -\n * The value to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZEmailContact): this {\n this._contact = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built email contact.\n */\n public build(): IZEmailContact {\n return JSON.parse(JSON.stringify(this._contact));\n }\n}\n","import { IZEmailContact } from './email-contact';\n\n/**\n * Represents a builder that will build a comma separated\n * list of addresses for an email message.\n */\nexport class ZEmailContactAddressBuilder {\n private _addresses: Array<string | IZEmailContact> = [];\n private _delimiter = ', ';\n\n /**\n * Adds an address to the list to builder.\n *\n * @param val -\n * The address to add. This can be the empty string,\n * null, or undefined.\n *\n * @returns\n * This object.\n */\n public address(val: string | IZEmailContact): this {\n this._addresses.push(val);\n return this;\n }\n\n /**\n * Sets the addresses to build from.\n *\n * @param val -\n * The address to set.\n *\n * @returns\n * This object.\n */\n public addresses(val: Array<string | IZEmailContact>) {\n this._addresses = val.slice();\n return this;\n }\n\n /**\n * Sets the delimiter to split the addresses with.\n *\n * The default is a comma with a space.\n *\n * @param val -\n * The delimiter to set.\n *\n * @returns\n * This object.\n */\n public delimiter(val: string): this {\n this._delimiter = val;\n return this;\n }\n\n /**\n * Builds the delimiters separated list of addresses.\n *\n * @returns\n * The delimited separated list of addresses.\n */\n public build(): string {\n const addr = (ct: string | IZEmailContact) => {\n if (!ct) {\n return undefined;\n }\n\n return typeof ct === 'string' ? ct : ct.address;\n };\n\n const truthy = (ct: string) => {\n return !!ct;\n };\n\n return this._addresses.map(addr).filter(truthy).join(this._delimiter);\n }\n}\n","/**\n * Represents an abstract server connection.\n */\nexport interface IZServer {\n /**\n * The host or ip address to connect to.\n *\n * Does not distinguish between the protocol and hostname.\n */\n address: string;\n\n /**\n * The optional port to connect on.\n *\n * If this is falsy, then it is up to the implementation\n * taking this object to properly default the value.\n */\n port?: number;\n\n /**\n * The optional username.\n *\n * Falsy usually implies guest access.\n */\n username?: string;\n\n /**\n * The user's password to connect with.\n *\n * If username is not supplied, then this generally has no meaning.\n */\n password?: string;\n}\n\n/**\n * Represents a builder for a server object.\n */\nexport class ZServerBuilder {\n private _server: IZServer;\n\n /**\n * Initializes a new instance of this object.\n */\n public constructor() {\n this._server = {\n address: ''\n };\n }\n\n /**\n * The server ip address or hostname.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public address(val: string): this {\n this._server.address = val;\n return this;\n }\n\n /**\n * Sets the optional port to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public port(val: number): this {\n this._server.port = val;\n return this;\n }\n\n /**\n * Sets the optional username to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public username(val: string): this {\n this._server.username = val;\n return this;\n }\n\n /**\n * Sets the password to connect on.\n *\n * @param val -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public password(val: string): this {\n this._server.password = val;\n return this;\n }\n\n /**\n * Assigns all truthy properties in other to this object.\n *\n * @param other -\n * The server object to copy.\n *\n * @returns\n * This object.\n */\n public assign(other: Partial<IZServer>): this {\n this._server = Object.assign({}, this._server, other);\n return this;\n }\n\n /**\n * Copies all properties in other to this object.\n *\n * @param other -\n * The server object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZServer): this {\n this._server = JSON.parse(JSON.stringify(other));\n return this;\n }\n\n /**\n * Returns a copy of the built object.\n *\n * @returns\n * A copy of the built object.\n */\n public build(): IZServer {\n return JSON.parse(JSON.stringify(this._server));\n }\n}\n"],"names":["ZCookieBuilder","_cookie","this","immortal","expires","bind","undefined","lax","sameSite","strict","name","value","_proto","prototype","val","domain","toJSON","expiresTomorrow","Date","now","MillisecondsOneDay","secure","allowCrossSite","httpOnly","authentication","token","builder","build","_extends","ZEmailEnvelopeBuilder","_envelope","from","to","push","tos","cc","ccs","bcc","bccs","assign","other","Object","JSON","parse","stringify","copy","ZEmailBuilder","_email","envelope","subject","message","ZEmailContactBuilder","_contact","address","type","display","ZEmailContactAddressBuilder","_addresses","_delimiter","addresses","slice","delimiter","map","ct","filter","join","ZServerBuilder","_server","port","username","password"],"mappings":"oOAqCa,IAAAA,eAAc,WAQzB,SAAAA,SALQC,aAAO,EAAAC,KA4FRC,SAAuBD,KAAKE,QAAQC,KAAKH,UAAMI,QAoC/CC,IAAML,KAAKM,SAASH,KAAKH,KAAM,OAQ/BO,KAAAA,OAASP,KAAKM,SAASH,KAAKH,KAAM,UAlIvCA,KAAKD,QAAU,CACbS,KAAM,GACNC,MAAO,GAEX,CAAC,IAAAC,EAAAZ,EAAAa,iBAAAD,EAWMF,KAAA,SAAKI,GAEV,OADAZ,KAAKD,QAAQS,KAAOI,EAEtBZ,IAAA,EAACU,EAWMD,MAAA,SAAMG,GAEX,OADAZ,KAAKD,QAAQU,MAAQG,EACdZ,IACT,EAACU,EAWMG,OAAA,SAAOD,GAEZ,OADAZ,KAAKD,QAAQc,OAASD,EACfZ,IACT,EAACU,EAWMR,QAAA,SAAQU,GACb,OAAW,MAAPA,UACSZ,KAACD,QAAQG,QACbF,OAGTA,KAAKD,QAAQG,QAAyB,iBAARU,EAAmBA,EAAMA,EAAIE,cAE7D,EAACJ,EAWMK,gBAAA,WACL,OAAWf,KAACE,QAAQ,IAAIc,KAAKA,KAAKC,MAAQnB,EAAeoB,oBAC3D,EAACR,EAmBMS,OAAA,SAAOP,GAEZ,YAFYA,IAAAA,IAAAA,GAAM,GAClBZ,KAAKD,QAAQoB,OAASP,EAExBZ,IAAA,EAACU,EAWMJ,SAAA,SAAS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eAMX,WAAA,SAAAA,IAAAhE,KALQiE,aAMN,EAAAjE,KAAKiE,QAAU,CACbd,QAAS,GAEb,CAAC,IAAAzC,EAAAsD,EAAArD,UA8FA,OA9FAD,EAWMyC,QAAA,SAAQvC,GAEb,OADAZ,KAAKiE,QAAQd,QAAUvC,EAChBZ,IACT,EAACU,EAWMwD,KAAA,SAAKtD,GAEV,OADAZ,KAAKiE,QAAQC,KAAOtD,MAEtB,EAACF,EAWMyD,SAAA,SAASvD,GAEd,OADAZ,KAAKiE,QAAQE,SAAWvD,EACjBZ,IACT,EAACU,EAWM0D,SAAA,SAASxD,GAEd,OADAZ,KAAKiE,QAAQG,SAAWxD,EAE1BZ,IAAA,EAACU,EAWM2B,OAAA,SAAOC,GAEZ,OADAtC,KAAKiE,QAAU1B,OAAOF,OAAO,CAAE,EAAErC,KAAKiE,QAAS3B,GAEjDtC,IAAA,EAACU,EAWMiC,KAAA,SAAKL,GAEV,OADAtC,KAAKiE,QAAUzB,KAAKC,MAAMD,KAAKE,UAAUJ,IAClCtC,IACT,EAACU,EAQMe,MAAA,WACL,OAAOe,KAAKC,MAAMD,KAAKE,UAAU1C,KAAKiE,SACxC,EAACD,CAAA,CAlGD"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a generic cookie.
|
|
3
|
+
*/
|
|
4
|
+
export interface IZCookie {
|
|
5
|
+
/**
|
|
6
|
+
* The cookie name.
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* The cookie value.
|
|
11
|
+
*/
|
|
12
|
+
value: string;
|
|
13
|
+
/**
|
|
14
|
+
* The scope domain attached to the cookie.
|
|
15
|
+
*/
|
|
16
|
+
domain?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The utc formatted date at which the cookie expires
|
|
19
|
+
*/
|
|
20
|
+
expires?: string;
|
|
21
|
+
/**
|
|
22
|
+
* A flag that determines if this is a secure cookie.
|
|
23
|
+
*/
|
|
24
|
+
secure?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* A flag that determines if this cookie can be ready by javascript.
|
|
27
|
+
*/
|
|
28
|
+
httpOnly?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* A value that determines how the cookie is sent by the browser.
|
|
31
|
+
*/
|
|
32
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a builder for an IZCookie object.
|
|
36
|
+
*/
|
|
37
|
+
export declare class ZCookieBuilder {
|
|
38
|
+
static readonly MillisecondsOneDay = 86400000;
|
|
39
|
+
private _cookie;
|
|
40
|
+
/**
|
|
41
|
+
* Initializes a new instance of this object.
|
|
42
|
+
*/
|
|
43
|
+
constructor();
|
|
44
|
+
/**
|
|
45
|
+
* Sets the cookie name.
|
|
46
|
+
*
|
|
47
|
+
* @param val -
|
|
48
|
+
* The value to set.
|
|
49
|
+
*
|
|
50
|
+
* @returns
|
|
51
|
+
* This object.
|
|
52
|
+
*/
|
|
53
|
+
name(val: string): this;
|
|
54
|
+
/**
|
|
55
|
+
* Sets the cookie value.
|
|
56
|
+
*
|
|
57
|
+
* @param val -
|
|
58
|
+
* The value to set.
|
|
59
|
+
*
|
|
60
|
+
* @returns
|
|
61
|
+
* This object.
|
|
62
|
+
*/
|
|
63
|
+
value(val: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the cookie domain.
|
|
66
|
+
*
|
|
67
|
+
* @param val -
|
|
68
|
+
* The value to set.
|
|
69
|
+
*
|
|
70
|
+
* @returns
|
|
71
|
+
* This object.
|
|
72
|
+
*/
|
|
73
|
+
domain(val: string | undefined): this;
|
|
74
|
+
/**
|
|
75
|
+
* Sets the cookie expiration date.
|
|
76
|
+
*
|
|
77
|
+
* @param val -
|
|
78
|
+
* The value to set.
|
|
79
|
+
*
|
|
80
|
+
* @returns
|
|
81
|
+
* This object.
|
|
82
|
+
*/
|
|
83
|
+
expires(val: Date | string | undefined): this;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the cookie expiration date to one day from the moment this is invoked.
|
|
86
|
+
*
|
|
87
|
+
* @param val -
|
|
88
|
+
* The value to set.
|
|
89
|
+
*
|
|
90
|
+
* @returns
|
|
91
|
+
* This object.
|
|
92
|
+
*/
|
|
93
|
+
expiresTomorrow(): this;
|
|
94
|
+
/**
|
|
95
|
+
* Removes the cookie expiration.
|
|
96
|
+
*
|
|
97
|
+
* @returns
|
|
98
|
+
* This object.
|
|
99
|
+
*/
|
|
100
|
+
immortal: () => this;
|
|
101
|
+
/**
|
|
102
|
+
* Sets the cookie secure flag.
|
|
103
|
+
*
|
|
104
|
+
* @param val -
|
|
105
|
+
* The value to set.
|
|
106
|
+
*
|
|
107
|
+
* @returns
|
|
108
|
+
* This object.
|
|
109
|
+
*/
|
|
110
|
+
secure(val?: boolean): this;
|
|
111
|
+
/**
|
|
112
|
+
* Sets the cookie same site policy.
|
|
113
|
+
*
|
|
114
|
+
* @param val -
|
|
115
|
+
* The value to set.
|
|
116
|
+
*
|
|
117
|
+
* @returns
|
|
118
|
+
* This object.
|
|
119
|
+
*/
|
|
120
|
+
sameSite(val: 'lax' | 'strict' | 'none'): this;
|
|
121
|
+
/**
|
|
122
|
+
* Sets the same site policy to 'lax'
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
* This object.
|
|
126
|
+
*/
|
|
127
|
+
lax: () => this;
|
|
128
|
+
/**
|
|
129
|
+
* Sets the same site polity to 'strict'
|
|
130
|
+
*
|
|
131
|
+
* @returns
|
|
132
|
+
* This object.
|
|
133
|
+
*/
|
|
134
|
+
strict: () => this;
|
|
135
|
+
/**
|
|
136
|
+
* Sets the same site policy to 'none' and turns on the secure flag.
|
|
137
|
+
*
|
|
138
|
+
* @returns
|
|
139
|
+
* This object.
|
|
140
|
+
*/
|
|
141
|
+
allowCrossSite(): this;
|
|
142
|
+
/**
|
|
143
|
+
* Sets the cookie http only flag.
|
|
144
|
+
*
|
|
145
|
+
* @param val -
|
|
146
|
+
* The value to set.
|
|
147
|
+
*
|
|
148
|
+
* @returns
|
|
149
|
+
* This object.
|
|
150
|
+
*/
|
|
151
|
+
httpOnly(val?: boolean): this;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a token based authentication cookie.
|
|
154
|
+
*
|
|
155
|
+
* @param token -
|
|
156
|
+
* The token value for the cookie. You
|
|
157
|
+
* can leave this as undefined to set it
|
|
158
|
+
* later.
|
|
159
|
+
*
|
|
160
|
+
* @returns
|
|
161
|
+
* This object.
|
|
162
|
+
*/
|
|
163
|
+
authentication(token?: string): this;
|
|
164
|
+
/**
|
|
165
|
+
* Returns a copy of the built instance of the cookie.
|
|
166
|
+
*
|
|
167
|
+
* @returns
|
|
168
|
+
* A shallow copy of the current cookie object.
|
|
169
|
+
*/
|
|
170
|
+
build(): IZCookie;
|
|
171
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IZEmailContact } from './email-contact';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a builder that will build a comma separated
|
|
4
|
+
* list of addresses for an email message.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ZEmailContactAddressBuilder {
|
|
7
|
+
private _addresses;
|
|
8
|
+
private _delimiter;
|
|
9
|
+
/**
|
|
10
|
+
* Adds an address to the list to builder.
|
|
11
|
+
*
|
|
12
|
+
* @param val -
|
|
13
|
+
* The address to add. This can be the empty string,
|
|
14
|
+
* null, or undefined.
|
|
15
|
+
*
|
|
16
|
+
* @returns
|
|
17
|
+
* This object.
|
|
18
|
+
*/
|
|
19
|
+
address(val: string | IZEmailContact): this;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the addresses to build from.
|
|
22
|
+
*
|
|
23
|
+
* @param val -
|
|
24
|
+
* The address to set.
|
|
25
|
+
*
|
|
26
|
+
* @returns
|
|
27
|
+
* This object.
|
|
28
|
+
*/
|
|
29
|
+
addresses(val: Array<string | IZEmailContact>): this;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the delimiter to split the addresses with.
|
|
32
|
+
*
|
|
33
|
+
* The default is a comma with a space.
|
|
34
|
+
*
|
|
35
|
+
* @param val -
|
|
36
|
+
* The delimiter to set.
|
|
37
|
+
*
|
|
38
|
+
* @returns
|
|
39
|
+
* This object.
|
|
40
|
+
*/
|
|
41
|
+
delimiter(val: string): this;
|
|
42
|
+
/**
|
|
43
|
+
* Builds the delimiters separated list of addresses.
|
|
44
|
+
*
|
|
45
|
+
* @returns
|
|
46
|
+
* The delimited separated list of addresses.
|
|
47
|
+
*/
|
|
48
|
+
build(): string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an email contact.
|
|
3
|
+
*/
|
|
4
|
+
export interface IZEmailContact {
|
|
5
|
+
/**
|
|
6
|
+
* The email address of the contact.
|
|
7
|
+
*/
|
|
8
|
+
address: string;
|
|
9
|
+
/**
|
|
10
|
+
* The type of contact.
|
|
11
|
+
*
|
|
12
|
+
* This can be anything you want. In the end, this has no bearing
|
|
13
|
+
* on the final sent message. It's just a descriptor to determine what this contact
|
|
14
|
+
* represents if needed.
|
|
15
|
+
*/
|
|
16
|
+
type?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The display name of the contact.
|
|
19
|
+
*
|
|
20
|
+
* If this is falsy, then you can consider the
|
|
21
|
+
* address as the display.
|
|
22
|
+
*/
|
|
23
|
+
display?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a builder for an email contact.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ZEmailContactBuilder {
|
|
29
|
+
private _contact;
|
|
30
|
+
/**
|
|
31
|
+
* Initializes a new instance of this object.
|
|
32
|
+
*/
|
|
33
|
+
constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Sets the address of the contact.
|
|
36
|
+
*
|
|
37
|
+
* @param val -
|
|
38
|
+
* The value to set.
|
|
39
|
+
*
|
|
40
|
+
* @returns
|
|
41
|
+
* This object.
|
|
42
|
+
*/
|
|
43
|
+
address(val: string): this;
|
|
44
|
+
/**
|
|
45
|
+
* Sets the type of the contact.
|
|
46
|
+
*
|
|
47
|
+
* @param val -
|
|
48
|
+
* The value to set.
|
|
49
|
+
*
|
|
50
|
+
* @returns
|
|
51
|
+
* This object.
|
|
52
|
+
*/
|
|
53
|
+
type(val: string): this;
|
|
54
|
+
/**
|
|
55
|
+
* Sets the display of the contact.
|
|
56
|
+
*
|
|
57
|
+
* @param val -
|
|
58
|
+
* The value to set.
|
|
59
|
+
*
|
|
60
|
+
* @returns
|
|
61
|
+
* This object.
|
|
62
|
+
*/
|
|
63
|
+
display(val: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Assigns the values in other to this object.
|
|
66
|
+
*
|
|
67
|
+
* @param other -
|
|
68
|
+
* The value to partial copy.
|
|
69
|
+
*
|
|
70
|
+
* @returns
|
|
71
|
+
* This object.
|
|
72
|
+
*/
|
|
73
|
+
assign(other: Partial<IZEmailContact>): this;
|
|
74
|
+
/**
|
|
75
|
+
* Copies another object.
|
|
76
|
+
*
|
|
77
|
+
* @param other -
|
|
78
|
+
* The value to copy.
|
|
79
|
+
*
|
|
80
|
+
* @returns
|
|
81
|
+
* This object.
|
|
82
|
+
*/
|
|
83
|
+
copy(other: IZEmailContact): this;
|
|
84
|
+
/**
|
|
85
|
+
* Returns a copy of the built object.
|
|
86
|
+
*
|
|
87
|
+
* @returns
|
|
88
|
+
* A copy of the built email contact.
|
|
89
|
+
*/
|
|
90
|
+
build(): IZEmailContact;
|
|
91
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { IZEmailContact } from './email-contact';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an email envelope of information about who the email is from and where it's going to.
|
|
4
|
+
*/
|
|
5
|
+
export interface IZEmailEnvelope {
|
|
6
|
+
/**
|
|
7
|
+
* Who the email is from.
|
|
8
|
+
*
|
|
9
|
+
* This can be the full contact or just the address.
|
|
10
|
+
*/
|
|
11
|
+
from: IZEmailContact | string;
|
|
12
|
+
/**
|
|
13
|
+
* Where the email is going.
|
|
14
|
+
*
|
|
15
|
+
* This can be falsy if cc is filled out.
|
|
16
|
+
*/
|
|
17
|
+
to?: Array<IZEmailContact | string>;
|
|
18
|
+
/**
|
|
19
|
+
* Who is receiving a carbon copy of the email.
|
|
20
|
+
*
|
|
21
|
+
* This can be falsy if to is filled out.
|
|
22
|
+
*/
|
|
23
|
+
cc?: Array<IZEmailContact | string>;
|
|
24
|
+
/**
|
|
25
|
+
* Who is receiving a blind carbon copy of an email.
|
|
26
|
+
*/
|
|
27
|
+
bcc?: Array<IZEmailContact | string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents a builder for an email envelope.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ZEmailEnvelopeBuilder {
|
|
33
|
+
private _envelope;
|
|
34
|
+
/**
|
|
35
|
+
* Initializes a new instance of this object.
|
|
36
|
+
*/
|
|
37
|
+
constructor();
|
|
38
|
+
/**
|
|
39
|
+
* Sets the from field.
|
|
40
|
+
*
|
|
41
|
+
* @param val -
|
|
42
|
+
* The value to set.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
* This object.
|
|
46
|
+
*/
|
|
47
|
+
from(val: IZEmailContact | string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Adds a value to the 'to' field.
|
|
50
|
+
*
|
|
51
|
+
* @param val -
|
|
52
|
+
* The value to add.
|
|
53
|
+
*
|
|
54
|
+
* @returns
|
|
55
|
+
* This object.
|
|
56
|
+
*/
|
|
57
|
+
to(val: IZEmailContact | string): this;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the to field.
|
|
60
|
+
*
|
|
61
|
+
* @param val -
|
|
62
|
+
* The value to set.
|
|
63
|
+
*
|
|
64
|
+
* @returns
|
|
65
|
+
* This object.
|
|
66
|
+
*/
|
|
67
|
+
tos(val: Array<IZEmailContact | string>): this;
|
|
68
|
+
/**
|
|
69
|
+
* Adds a value to the cc field.
|
|
70
|
+
*
|
|
71
|
+
* @param val -
|
|
72
|
+
* The value to add.
|
|
73
|
+
*
|
|
74
|
+
* @returns
|
|
75
|
+
* This object.
|
|
76
|
+
*/
|
|
77
|
+
cc(val: IZEmailContact | string): this;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the cc field.
|
|
80
|
+
*
|
|
81
|
+
* @param val -
|
|
82
|
+
* The value to set.
|
|
83
|
+
*
|
|
84
|
+
* @returns
|
|
85
|
+
* This object.
|
|
86
|
+
*/
|
|
87
|
+
ccs(val: Array<IZEmailContact | string>): this;
|
|
88
|
+
/**
|
|
89
|
+
* Adds a value to the bcc field.
|
|
90
|
+
*
|
|
91
|
+
* @param val -
|
|
92
|
+
* The value to add.
|
|
93
|
+
*
|
|
94
|
+
* @returns
|
|
95
|
+
* This object.
|
|
96
|
+
*/
|
|
97
|
+
bcc(val: IZEmailContact | string): this;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the bcc field.
|
|
100
|
+
*
|
|
101
|
+
* @param val -
|
|
102
|
+
* The value to set.
|
|
103
|
+
*
|
|
104
|
+
* @returns
|
|
105
|
+
* This object.
|
|
106
|
+
*/
|
|
107
|
+
bccs(val: Array<IZEmailContact | string>): this;
|
|
108
|
+
/**
|
|
109
|
+
* Assigns another partial email envelope to this object.
|
|
110
|
+
*
|
|
111
|
+
* @param other -
|
|
112
|
+
* The value to partial copy.
|
|
113
|
+
*
|
|
114
|
+
* @returns
|
|
115
|
+
* This object.
|
|
116
|
+
*/
|
|
117
|
+
assign(other: Partial<IZEmailEnvelope>): this;
|
|
118
|
+
/**
|
|
119
|
+
* Copies another email envelope to this object.
|
|
120
|
+
*
|
|
121
|
+
* @param other -
|
|
122
|
+
* The value to copy.
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
* This object.
|
|
126
|
+
*/
|
|
127
|
+
copy(other: IZEmailEnvelope): this;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a copy of the built envelope.
|
|
130
|
+
*
|
|
131
|
+
* @returns
|
|
132
|
+
* A copy of the currently built up envelope object.
|
|
133
|
+
*/
|
|
134
|
+
build(): IZEmailEnvelope;
|
|
135
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { IZEmailEnvelope } from './email-envelope';
|
|
2
|
+
/**
|
|
3
|
+
* Represents an email message.
|
|
4
|
+
*/
|
|
5
|
+
export interface IZEmail {
|
|
6
|
+
/**
|
|
7
|
+
* The email envelope of where the email is going to.
|
|
8
|
+
*/
|
|
9
|
+
envelope: IZEmailEnvelope;
|
|
10
|
+
/**
|
|
11
|
+
* The subject (title) of the email.
|
|
12
|
+
*/
|
|
13
|
+
subject?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The message to send.
|
|
16
|
+
*/
|
|
17
|
+
message?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents a builder for an email.
|
|
21
|
+
*/
|
|
22
|
+
export declare class ZEmailBuilder {
|
|
23
|
+
private _email;
|
|
24
|
+
/**
|
|
25
|
+
* Initializes a new instance of this object.
|
|
26
|
+
*/
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Sets the envelope of where the email is going.
|
|
30
|
+
*
|
|
31
|
+
* @param val -
|
|
32
|
+
* The value to set.
|
|
33
|
+
*
|
|
34
|
+
* @returns
|
|
35
|
+
* This object.
|
|
36
|
+
*/
|
|
37
|
+
envelope(val: IZEmailEnvelope): this;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the subject line of the email.
|
|
40
|
+
*
|
|
41
|
+
* @param val -
|
|
42
|
+
* The value to set.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
* This object.
|
|
46
|
+
*/
|
|
47
|
+
subject(val: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the message of the email.
|
|
50
|
+
*
|
|
51
|
+
* The message can be raw text or html.
|
|
52
|
+
*
|
|
53
|
+
* @param val -
|
|
54
|
+
* A html enabled formatted message to set.
|
|
55
|
+
*
|
|
56
|
+
* @returns
|
|
57
|
+
* This object.
|
|
58
|
+
*/
|
|
59
|
+
message(val: string): this;
|
|
60
|
+
/**
|
|
61
|
+
* Assigns the other object to the current email object.
|
|
62
|
+
*
|
|
63
|
+
* @param other -
|
|
64
|
+
* The object to copy.
|
|
65
|
+
*
|
|
66
|
+
* @returns
|
|
67
|
+
* This object.
|
|
68
|
+
*/
|
|
69
|
+
assign(other: Partial<IZEmail>): this;
|
|
70
|
+
/**
|
|
71
|
+
* Copies another email into the builder.
|
|
72
|
+
*
|
|
73
|
+
* @param other -
|
|
74
|
+
* The object to copy.
|
|
75
|
+
*
|
|
76
|
+
* @returns
|
|
77
|
+
* This object.
|
|
78
|
+
*/
|
|
79
|
+
copy(other: IZEmail): this;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a copy of the built object.
|
|
82
|
+
*
|
|
83
|
+
* @returns
|
|
84
|
+
* A copy of the built object.
|
|
85
|
+
*/
|
|
86
|
+
build(): IZEmail;
|
|
87
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an abstract server connection.
|
|
3
|
+
*/
|
|
4
|
+
export interface IZServer {
|
|
5
|
+
/**
|
|
6
|
+
* The host or ip address to connect to.
|
|
7
|
+
*
|
|
8
|
+
* Does not distinguish between the protocol and hostname.
|
|
9
|
+
*/
|
|
10
|
+
address: string;
|
|
11
|
+
/**
|
|
12
|
+
* The optional port to connect on.
|
|
13
|
+
*
|
|
14
|
+
* If this is falsy, then it is up to the implementation
|
|
15
|
+
* taking this object to properly default the value.
|
|
16
|
+
*/
|
|
17
|
+
port?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The optional username.
|
|
20
|
+
*
|
|
21
|
+
* Falsy usually implies guest access.
|
|
22
|
+
*/
|
|
23
|
+
username?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The user's password to connect with.
|
|
26
|
+
*
|
|
27
|
+
* If username is not supplied, then this generally has no meaning.
|
|
28
|
+
*/
|
|
29
|
+
password?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents a builder for a server object.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ZServerBuilder {
|
|
35
|
+
private _server;
|
|
36
|
+
/**
|
|
37
|
+
* Initializes a new instance of this object.
|
|
38
|
+
*/
|
|
39
|
+
constructor();
|
|
40
|
+
/**
|
|
41
|
+
* The server ip address or hostname.
|
|
42
|
+
*
|
|
43
|
+
* @param val -
|
|
44
|
+
* The value to set.
|
|
45
|
+
*
|
|
46
|
+
* @returns
|
|
47
|
+
* This object.
|
|
48
|
+
*/
|
|
49
|
+
address(val: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the optional port to connect on.
|
|
52
|
+
*
|
|
53
|
+
* @param val -
|
|
54
|
+
* The value to set.
|
|
55
|
+
*
|
|
56
|
+
* @returns
|
|
57
|
+
* This object.
|
|
58
|
+
*/
|
|
59
|
+
port(val: number): this;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the optional username to connect on.
|
|
62
|
+
*
|
|
63
|
+
* @param val -
|
|
64
|
+
* The value to set.
|
|
65
|
+
*
|
|
66
|
+
* @returns
|
|
67
|
+
* This object.
|
|
68
|
+
*/
|
|
69
|
+
username(val: string): this;
|
|
70
|
+
/**
|
|
71
|
+
* Sets the password to connect on.
|
|
72
|
+
*
|
|
73
|
+
* @param val -
|
|
74
|
+
* The value to set.
|
|
75
|
+
*
|
|
76
|
+
* @returns
|
|
77
|
+
* This object.
|
|
78
|
+
*/
|
|
79
|
+
password(val: string): this;
|
|
80
|
+
/**
|
|
81
|
+
* Assigns all truthy properties in other to this object.
|
|
82
|
+
*
|
|
83
|
+
* @param other -
|
|
84
|
+
* The server object to copy.
|
|
85
|
+
*
|
|
86
|
+
* @returns
|
|
87
|
+
* This object.
|
|
88
|
+
*/
|
|
89
|
+
assign(other: Partial<IZServer>): this;
|
|
90
|
+
/**
|
|
91
|
+
* Copies all properties in other to this object.
|
|
92
|
+
*
|
|
93
|
+
* @param other -
|
|
94
|
+
* The server object to copy.
|
|
95
|
+
*
|
|
96
|
+
* @returns
|
|
97
|
+
* This object.
|
|
98
|
+
*/
|
|
99
|
+
copy(other: IZServer): this;
|
|
100
|
+
/**
|
|
101
|
+
* Returns a copy of the built object.
|
|
102
|
+
*
|
|
103
|
+
* @returns
|
|
104
|
+
* A copy of the built object.
|
|
105
|
+
*/
|
|
106
|
+
build(): IZServer;
|
|
107
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zthun/helpful-internet",
|
|
3
|
+
"version": "0.21.0",
|
|
4
|
+
"description": "Helpful objects that represents internet base entities",
|
|
5
|
+
"author": "Anthony Bonta",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zthun/helpful",
|
|
10
|
+
"directory": "packages/helpful-internet"
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/lib/index.js",
|
|
13
|
+
"module": "./dist/lib/index.esm.js",
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "microbundle --format esm,cjs --tsconfig tsconfig.prod.json"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@zthun/helpful-fn": "^0.21.0",
|
|
23
|
+
"microbundle": "^0.15.1",
|
|
24
|
+
"vite": "^4.4.7",
|
|
25
|
+
"vitest": "^0.33.0"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"gitHead": "ee5bff46d3b9574b6b9c3fafd42127356eb95930"
|
|
32
|
+
}
|